templates/content/tmpl/mtm-module-loop.html.twig line 1

Open in your IDE?
  1. {% set form_attr = { 
  2.     thankyou: page.getContentMetaValueByKey("lp_thankyou"),
  3.     btn_text: page.getContentMetaValueByKey("lp_button"),
  4.     btn_color: page.getContentMetaValueByKey("rcs_call_to_action_color")
  5. } %}
  6. {% for i in 0 .. (modules | length) - 1 %}
  7.     {# walk down modules and build blocks #}
  8.     {% set mod_bg = page.getContentMetaValueByKey("mtm_content_modules_#{i}_rcs_element_background_color") %}
  9.     {% set mod_title = page.getContentMetaValueByKey("mtm_content_modules_#{i}_mtm_text_area_title") %}
  10.     {% set mod_title_color = page.getContentMetaValueByKey("mtm_content_modules_#{i}_rcs_module_title_color") %}
  11.     
  12.     {# set some defaults #}
  13.     {% if mod_bg is empty %}
  14.         {% set mod_bg = "#fff" %}
  15.     {% endif %}
  16.     
  17.     {% if mod_title_color is empty %}
  18.         {% set mod_title_color = "#222" %}
  19.     {% endif %}
  20.     
  21.     {% if modules[i] == "mtm_module_hero_image" %}
  22.         {% set mod_subhead = page.getContentMetaValueByKey("mtm_content_modules_#{i}_mtm_hero_subheading") %}
  23.         {% set mod_image = page.getContentMetaValueByKey("mtm_content_modules_#{i}_mtm_hero_image") %}
  24.         
  25.         {% if mod_image is not empty or mod_subhead is not empty %}
  26.             <div class="row" style="min-height: 10px">
  27.                 <div class="col-sm-12" style="background: {{ mod_bg }}; {% if mod_image is not empty %} padding-bottom: 15px; {% endif %}">
  28.             
  29.             {% set mod_sub = page.getContentMetaValueByKey("mtm_content_modules_#{i}_mtm_hero_subheading") %}
  30.             {% if mod_image is not empty %}
  31.                 {% set mod_image = get_entity("Media", "old_id", mod_image) %}
  32.                 {% if mod_image is not empty %}
  33.                     <img 
  34.                         class="mod-hero-image"
  35.                         src="{{ mod_image.getURL() }}"
  36.                         alt="{{ mod_image.getTitle() }}"
  37.                         style="visibility: hidden; display: block;"
  38.                         loading='lazy'
  39.                     />
  40.                     <img 
  41.                         class="mod-hero-image"
  42.                         src="{{ mod_image.getURL() }}"
  43.                         alt="{{ mod_image.getTitle() }}"
  44.                         style="position:absolute; top: 0; left: 0; right: -15px; width: 100%;"
  45.                         loading='lazy'
  46.                     />
  47.                 {% endif %}
  48.             {% endif %}
  49.             {% if mod_subhead is not empty %}
  50.                 {% if mod_image is not empty %}
  51.                     <div style="padding-top: 20px;">
  52.                 {% endif %}
  53.                 {{ mod_subhead | wordpress | raw }}
  54.                 {% if mod_image is not empty %}
  55.                     </div>
  56.                 {% endif %}
  57.             {% endif %}
  58.                 </div>
  59.             </div>
  60.         {% endif %}
  61.     {% elseif modules[i] == "mtm_module_single_content_area" %}
  62.         {% set mod_text = page.getContentMetaValueByKey("mtm_content_modules_#{i}_mtm_module_text_area") %}
  63.         
  64.         {% if mod_text is not empty %}
  65.         <div class="row">
  66.             <div class="col-md-12 p-3" style="background: {{ mod_bg }};">
  67.                 {% if mod_title is not empty %}
  68.                     <h2 
  69.                         class="mod-title"
  70.                         style="color: {{ mod_title_color }};"
  71.                     >{{ mod_title }}</h2>
  72.                 {% endif %}
  73.                 {% if mod_text is not empty %}
  74.                     {{ mod_text | wordpress(form_attr) | raw }}
  75.                 {% endif %}
  76.             </div>
  77.         </div>
  78.         {% endif %}
  79.     
  80.     {% elseif modules[i] == "mtm_module_dual_content_area" %}
  81.         {% set mod_text = page.getContentMetaValueByKey("mtm_content_modules_#{i}_mtm_module_text_area") %}
  82.         
  83.         {% set mod_text2 = page.getContentMetaValueByKey("mtm_content_modules_#{i}_mtm_module_text_area_2") %}
  84.         {% set mod_bg2 = page.getContentMetaValueByKey("mtm_content_modules_#{i}_rcs_element_background_color_2") %}
  85.         {% set mod_title2 = page.getContentMetaValueByKey("mtm_content_modules_#{i}_mtm_text_area_title_2") %}
  86.         {% set mod_title_color2 = page.getContentMetaValueByKey("mtm_content_modules_#{i}_rcs_module_title_color_2") %}
  87.         
  88.         {% if mod_bg2 is empty %}
  89.             {% set mod_bg2 = "#fff" %}
  90.         {% endif %}
  91.         
  92.         {% if mod_title_color2 is empty %}
  93.             {% set mod_title_color2 = "#222" %}
  94.         {% endif %}
  95.         
  96.         <div class="row">
  97.             <div class="col-md-6 p-3" style="background: {{ mod_bg }};">
  98.                 {% if mod_title is not empty %}
  99.                     <h2 
  100.                         class="mod-title"
  101.                         style="color: {{ mod_title_color }};"
  102.                     >{{ mod_title }}</h2>
  103.                 {% endif %}
  104.                 {% if mod_text is not empty %}
  105.                     {{ mod_text | wordpress(form_attr) | raw }}
  106.                 {% endif %}
  107.             </div>
  108.             <div class="col-md-6 p-3" style="background: {{ mod_bg2 }};">
  109.                 {% if mod_title2 is not empty %}
  110.                     <h2 
  111.                         class="mod-title"
  112.                         style="color: {{ mod_title_color }};"
  113.                     >{{ mod_title2 }}</h2>
  114.                 {% endif %}
  115.                 {% if mod_text2 is not empty %}
  116.                     {{ mod_text2 | wordpress(form_attr) | raw }}
  117.                 {% endif %}
  118.             </div>
  119.         </div>
  120.     
  121.     {% elseif modules[i] == "mtm_module_listgrid" %}
  122.         {# list grid #}
  123.         {% set looping = true %}
  124.         {% for j in 0..5000 %}
  125.             {% if looping %}
  126.                 {% set grid_heading = page.getContentMetaValueByKey("mtm_content_modules_#{i}_mtm_add_list_item_#{j}_mtm_list_item_heading") %}
  127.                 {% set grid_link = page.getContentMetaValueByKey("mtm_content_modules_#{i}_mtm_add_list_item_#{j}_mtm_list_item_link") %}
  128.                 {% set grid_image = page.getContentMetaValueByKey("mtm_content_modules_#{i}_mtm_add_list_item_#{j}_mtm_list_item_image") %}
  129.                 
  130.                 {% if grid_heading is empty %}
  131.                     {% set looping = false %}
  132.                 {% endif %}
  133.                 
  134.                 {% if j == 50  %}
  135.                 <div class="row">
  136.                     <div class="col-md-12">
  137.                     <h1 id="2017" style="margin-bottom:unset">2017</h1>
  138.                     <hr style="border-top: 6px solid #a6252a; margin-top: unset;">
  139.                     </div>
  140.                 </div>
  141.                 {% elseif j == 102 %}
  142.                 <div class="row">
  143.                 <div class="col-md-12">
  144.                     <h1 id="2016" style="margin-bottom:unset">2016</h1>
  145.                     <hr style="border-top: 6px solid #a6252a; margin-top: unset;" />
  146.                 </div>
  147.                 </div>
  148.                 {% endif %}
  149.                 
  150.                 <div class="row my-3">
  151.                     {% if grid_image is not empty %}
  152.                         {% set grid_image = get_entity("Media", "old_id", grid_image) %}
  153.                         <div class="col-md-3">
  154.                             {% if grid_image is not empty %}
  155.                             <a href="{{ grid_link }}" ><img 
  156.                                 class="mod-gridlist-image"
  157.                                 src="{{ grid_image.getURL() }}"
  158.                                 alt="{{ grid_image.getTitle() }}"/></a>
  159.                             {% else %}
  160.                                 [default image]
  161.                             {% endif %}
  162.                         </div>
  163.                         <div class="col-md-9">
  164.                     {% else %}
  165.                         <div class="col-md-12">
  166.                     {% endif %}
  167.                         <a href="{{ grid_link }}" >{{ grid_heading }}</a>
  168.                     </div>
  169.                 </div>
  170.             {% endif %}
  171.         {% endfor %}
  172.         
  173.     {% elseif modules[i] == "mtm_module_gridlist_posts" %}
  174.         {# eg. /meet-rcs-influencers #}
  175.         
  176.         {% set grid_cols = page.getContentMetaValueByKey("mtm_content_modules_#{i}_mtm_grid_archive_per_row") %}
  177.         {% set grid_type = page.getContentMetaValueByKey("mtm_content_modules_#{i}_mtm_list_archive_select") %}
  178.         
  179.         {% if grid_type == 'Add Posts Manually' %}
  180.             {% set grid_posts = page.getContentMetaValueByKey("mtm_content_modules_#{i}_mtm_list_archive_manual_posts") %}
  181.             {% set grid_posts = unserialize(grid_posts) %}
  182.             
  183.             {% set gi = 0 %}
  184.             <div class="row">
  185.             {% for post_id in grid_posts %}
  186.                 {% if gi is not empty and gi is divisible by(grid_cols) %}
  187.                     </div>
  188.                     <div class="row">
  189.                 {% endif %}
  190.                 <div class="col-md-{{ 12 / grid_cols }}">
  191.                     {% set grid_content = get_entity("Content", "old_id", post_id) %}
  192.                     {% if grid_content is not empty %}
  193.                         <a href="{{ grid_content.getURL() }}">
  194.                         {{ grid_content.getFeaturedImageTag("","")|raw }}
  195.                         </a>
  196.                         
  197.                         <a href="{{ grid_content.getURL() }}">{{ grid_content.getTitle() }} </a>
  198.                     {% endif %}
  199.                 </div>
  200.                 {% set gi = gi + 1 %}
  201.             {% endfor %}
  202.             </div>
  203.         {% endif %}
  204.         
  205.     {% elseif modules[i] == "mtm_module_logo_showcase" %}
  206.         {# eg. /partners #}
  207.         
  208.         {% set logo_count = page.getContentMetaValueByKey("mtm_content_modules_#{i}_mtm_logo_repeater") %}
  209.         {% set trade_count = page.getContentMetaValueByKey("rcs_trade_association_repeater") %}  
  210.         
  211.         {% if logo_count is not empty %}
  212.             {#<div class="row">#}<ul style="width: 100%; display: table; table-layout: fixed; border-collapse: collapse;">
  213.             {% for j in 0 .. (logo_count - 1) %}
  214.             {# % set logo_image = page.getContentMetaValueByKey("mtm_content_modules_#{i}_mtm_logo_repeater_#{j}_mtm_logo_image") % #}
  215.             {% set logo_image = page.getContentMetaValueByKey("mtm_content_modules_#{i}_mtm_logo_repeater_#{j}_mtm_logo_image") %}
  216.             {% set logo_link = page.getContentMetaValueByKey("mtm_content_modules_#{i}_mtm_logo_repeater_#{j}_mtm_logo_link") %}
  217.             {% set logo_image = get_entity("Media", "old_id", logo_image) %}
  218.             
  219.                 {% if logo_image is not empty %}
  220.                 {#<div class="col-md-3">#}<li style="display: table-cell; text-align: center; vertical-align: middle; padding: 1.7em 1em;">
  221.                     {% if logo_link is not empty %}
  222.                         <a href="{{ logo_link }}">
  223.                     {% endif %}
  224.                     <img
  225.                         src="{{ logo_image.getURL() }}"
  226.                         title="{{ logo_image.getTitle() }}"
  227.                         loading='lazy'
  228.                     />
  229.                     {% if logo_link is not empty %}
  230.                         </a>
  231.                     {% endif %}
  232.                 {#</div>#}</li>
  233.                 {% endif %}
  234.             {% endfor %}
  235.             {#</div>#}</ul>
  236.         {% endif %}
  237.         
  238.         {% if trade_count is not empty %}
  239.                 
  240.             {% for j in 0 .. (trade_count - 1) %}
  241.                 {% set trade_name = page.getContentMetaValueByKey("rcs_trade_association_repeater_#{j}_rcs_trade_association_name") %}
  242.                 {% set trade_website = page.getContentMetaValueByKey("rcs_trade_association_repeater_#{j}_rcs_trade_association_website") %}
  243.                 {% set trade_location = page.getContentMetaValueByKey("rcs_trade_association_repeater_#{j}_rcs_trade_association_location") %}
  244.                 {% set trade_phone = page.getContentMetaValueByKey("rcs_trade_association_repeater_#{j}_rcs_trade_association_phone_number") %}
  245.                 <div class="row my-3">
  246.                     <div class="col-md-12">
  247.                         <h4 class="my-0">{{ trade_name }}</h4>
  248.                         <div class="trade-association--info">
  249.                         <p class="my-0">{{ trade_location }} | {{ trade_phone }}</p>
  250.                         <a  href="{{ trade_website }}">Visit Website</a>
  251.                         </div>
  252.                     </div>
  253.                 </div>
  254.             {% endfor %}
  255.         
  256.         {% endif %}
  257.         
  258.     
  259.     {% endif %}
  260. {% endfor %}