Forum for discussing general topics related to Couch.
2 posts Page 1 of 1
Is it possible to have menu.php for 2 purposes?
1. It creates a template (thanks to cms:template + cms:editable)
2. It contains HTML tags for embedding menu.php into index.php, about.php...


Menu.php:
Code: Select all
<?php require_once("admin/cms.php");?>

    <cms:template title="Menu" icon="menu" executable='0'>

        <cms:repeatable name="menu" label="Menu" desc="změny se propíší do hlavního menu, mobilního menu i zápatí">
            <cms:editable name="menu_name" label="Název položky" type="text"/>
            <cms:editable name="link" label="Odkaz" type="text"/>
        </cms:repeatable>

    </cms:template>


     <!-- Nav -->
     <div class="hidden h-10 font-alata md:flex md:space-x-8">
         <cms:show_repeatable "menu">
              <a href="<cms:show link/>" class="mx-2 border-b-2 border-transparent hover:border-blue-50"><cms:show menu_name/></a>
         </cms:show_repeatable>
      </div>


<?php COUCH::invoke();?>
The way embeds work, a snippet embedded into a template is almost exactly as if its contents were physically present in that spot of the template i.e. the snippet becomes a part of the template it is embedded in.

Considering what is said above, if we try to embed menu.php into another template e.g. about.php, this is what will happen -
The <cms:template> would be considered as executing from within about.php and corresponding changes will be made in about.php - i.e. its title etc. would change and the repeatable region would be created for it.
The same thing will happen with index.php if we try and embed menu.php in it.

This is not what we want and so the answer to your query is that - no, a bonafide template cannot be embedded into another template without causing unexpected behavior.
2 posts Page 1 of 1