Forum
navigation inside content template
I am trying to include navigation inside a hero banner template file. I have the following setup:
Files system
cms/
--templates/
----content/
------hero.html
----navigation/
------menu.html
----pages/
------home.php
And these are the template files:
hero-banner.html
<div class="c-hero-banner">
<nav class="c-primary-nav">
<perch:template path="navigation/menu.html">
</nav>
</div>
...
home.php
....
<?php perch_content_create('Hero Banner', array(
'template' => 'hero-banner.html',
));
?>
<?php perch_pages_navigation(array(
'navgroup' =>'header',
'template' => 'menu.html',
'levels' => 1
), true); ?>
<?php perch_content_custom('Hero Banner'); ?>
....
When I run it, all I get is the navigation menu outside the hero banner and an empty menu inside. Making perch_pages_navigation(...) a variable doesn't work, it just removes the menu outside the hero banner.
Is there a way to make perch:template inside hero-banner.html use the perch_pages_navigation()?
Neal, in your code this isn't going to output anything because you have not assigned the output to a variable
You would need to do something like this
Now you would need to
echo
the variable$navigation
or pass it into your template...Hello Neal,
You're almost there.
First, like Robert mentioned, you should assign a variable. Then you need to pass the variable to the template:
Then in your content template, you can output it like so:
If you're using an older version of Perch:
Thanks. That works great!