Reuse modular content in a different layout?


#1

Basically
I want to use the content of _menulist on another page and with a different layout

footer/_menulist uses template/modular/menus.html.twig

and I want
home/_features with template/modular/menus-features.html.twig ( a layout similar to quark features)

If I create a page home/_features and enable twig I can access the content of _menulist in the same layout of the footer

{% if page.find(’/footer/_menulist’).published == ‘true’ %}
{{ page.find(’/footer/_menulist’).content }}
{% endif %}

the Million dollar question,

Can I change the layout to menus-features?
and if yes what is the best practice or is my logic way off?
I don’t want to be duplicating content.

Thanks for the insights!!!


Here’s where I’m at…

modular footer

/footer modular

In the footer I have a menu list

/footer/_menulist

The _menulist is created with a custom modular page called menus

The menu template is located template/modular/menus.html.twig and contains this

{% set menu_title = page.header.menu  %}
{% if page.header.menu %}<h3>{{ menu_title }}</h3>{% endif %}
<ul>
{% for menu_items in page.header.menu_items %}
<li>
{% if menu_items.url %}<a href="{{ menu_items.url }}">{% endif %}
<i class="fa fa-fw {{ menu_items.icon }}"></i>
{% if menu_items.taxonomy and menu_items.tax == 'yes' %}
{{ menu_items.taxonomy }}
{% else %}
{{ menu_items.text }}
{% endif %}
{% if menu_items.url %}</a>{% endif %}
{% if menu_items.description and menu_items.desc == 'yes'%}
{{ menu_items.description }}
{% endif %}
</li>
{% endfor %}
</ul>

with blueprints/modular/menus.yaml

title: Menus
'@extends': default

form:
  fields:
    tabs:
      fields:
        features:
          type: tab
          title: Menus
          fields:
            header.menu:
              name: menu
              type: text
              label: Menu Name

            header.menu_items:
              name: menu_items
              type: list
              label: Menu Items

              fields:
                .icon:
                  type: iconpicker
                  label: Icon
                .text:
                  type: text
                  label: Text
                .taxonomy:
                  type: text
                  label: Taxonomy
                .tax:
                  type: text
                  label: Use Taxonomy (yes or no)
                  default: no
                .url:
                  type: text
                  label: Link
                  description: Use full https url for exterior links
                .description:
                  type: textarea
                  label: Description of link
                .desc:
                  type: text
                  label: Show the above description (yes or no)
                  default: no
                .aff:
                  type: text
                  label: Is this an affiliate link (yes or no)
                  default: no
                .hide:
                  type: text
                  label: Hide This (yes or no)
                  default: no

Works as I need by placing this in the footer.html

{% if page.find('/footer/_filing-paper').published == 'true' %}
<div class="column {{ columns }} twf">
{{ page.find('/footer/_menulist').content }}
</div>
{% endif %}

**this is my menus-features.html.twig **

{% set menu_title = page.header.menu %}
{% if page.header.menu %}

{{ menu_title }}

{% endif %}
{% set grid_size = theme_var(‘grid-size’) %}
{% set columns = page.header.class == ‘small’ ? ‘col-4 col-md-6 col-sm-6’ : ‘col-4 col-md-6 col-sm-6’ %}
{{ content|raw }}
{% for menu_items in page.header.menu_items %}
{% endfor %}

Is it just me... or is anyone else challenged with menu creation?