Skip to content

Commit

Permalink
Updates template for Parallax Offset field addition
Browse files Browse the repository at this point in the history
Renders and sets xeno_offset field as Twig variable parallax_offset.
Changes data-offset attribute to use parallax_offset Twig variable.
Excludes xeno_offset field from content being rendered.
  • Loading branch information
thejimbirch committed Aug 16, 2017
1 parent 3ceaca8 commit 04e1ef6
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions templates/paragraph--xeno-hero.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@ view_mode ? 'paragraph--view-mode--' ~ view_mode|clean_class,
%}
{% endif %}

{# Renders Parallax Offset field. #}
{# Sets data attibute value from user input. #}
{% if content.xeno_offset|render %}
{% set parallax_offset = content.xeno_offset['#items'].getString() %}
{% endif %}

{# Renders Invert field. #}
{# Sets class from values in database. #}
{% if content.xeno_invert|render %}
Expand Down Expand Up @@ -126,11 +132,11 @@ view_mode ? 'paragraph--view-mode--' ~ view_mode|clean_class,
{% endif %}

{# Prints div with classes, & content w/o img/invert/overlay/parallax fields. #}
<div{{ attributes.addClass(classes).setAttribute('data-overlay', overlay_levels).setAttribute('data-speed', parallax_speeds).setAttribute('data-offset', content.xeno_offset['#items'].getString()) }}>
<div{{ attributes.addClass(classes).setAttribute('data-overlay', overlay_levels).setAttribute('data-speed', parallax_speeds).setAttribute('data-offset', parallax_offset) }}>
{% if content.xeno_background_image|render %}
<div class="paragraph--type--xeno-hero__image">
{{ content.xeno_background_image }}
</div>
{% endif %}
{{ content|without('xeno_background_image', 'xeno_invert', 'xeno_overlay', 'xeno_parallax') }}
{{ content|without('xeno_background_image', 'xeno_invert', 'xeno_offset', 'xeno_overlay', 'xeno_parallax') }}
</div>

0 comments on commit 04e1ef6

Please sign in to comment.