Autonav - Dynamically Print Or Display Parent List Item
Permalink
I am working on a responsive push nav that displays the parent list item as a category name when viewing the level below. In short, the structure looks like this:
<ul>
<li>parent1
<ul>
<h2>parent1</h2> <!--Display Parent As Catagor Title-->
<li>Child1</li>
<li>Child2</li>
</ul>
</li>
</ul>
I am also looking for a way to display the parent list item as a title for the third and possibly fourth level. Blelow is a live example of what I am trying to integrate into C5.
http://tympanus.net/Development/MultiLevelPushMenu/index3.html...
Thanks!!
<ul>
<li>parent1
<ul>
<h2>parent1</h2> <!--Display Parent As Catagor Title-->
<li>Child1</li>
<li>Child2</li>
</ul>
</li>
</ul>
I am also looking for a way to display the parent list item as a title for the third and possibly fourth level. Blelow is a live example of what I am trying to integrate into C5.
http://tympanus.net/Development/MultiLevelPushMenu/index3.html...
Thanks!!
you'll have to create a custom template to achieve this. Copy /concrete/blocks/autonav/view.php to /blocks/autonav/templates/my-nav.php, make your modifications there and select that template by clicking on the block after you've added it.
Thanks for your response Remo!
I was planning in creating a custom template as suggested, but the issue is getting the parent to be dynamically inserted into the <h2> tag. Is there a way to pull that with php or jquery? I would prefer not to hardcode the parent values and have them inserted automatically.
Side note. I have seen several of your tutorials. Thanks for all of the hard work you have put into c5 documentation. Your efforts have helped me with many other challenges.
I was planning in creating a custom template as suggested, but the issue is getting the parent to be dynamically inserted into the <h2> tag. Is there a way to pull that with php or jquery? I would prefer not to hardcode the parent values and have them inserted automatically.
Side note. I have seen several of your tutorials. Thanks for all of the hard work you have put into c5 documentation. Your efforts have helped me with many other challenges.
Put the code in your theme's header page
<?php
$bt_main = BlockType::getByHandle('autonav');
$bt_main->controller->orderBy = 'display_asc';
$bt_main->controller->displaySubPages = 'all';
$bt_main->controller->displaySubPageLevels = 'custom'; $bt_main->controller->displaySubPageLevelsNum = '2';
$bt_main->render('templates/view');
?>
and copy /concrete/blocks/autonav/view.php file to /blocks/autonav/view.php
<?php
$bt_main = BlockType::getByHandle('autonav');
$bt_main->controller->orderBy = 'display_asc';
$bt_main->controller->displaySubPages = 'all';
$bt_main->controller->displaySubPageLevels = 'custom'; $bt_main->controller->displaySubPageLevelsNum = '2';
$bt_main->render('templates/view');
?>
and copy /concrete/blocks/autonav/view.php file to /blocks/autonav/view.php
Where the jquery gurus at? The has to be a way to grab that parent list item and print it into the h2 tags. Jordan Lev, help a brother out. The auto nav king appeared and saved me last time i said his name.
there's no need for jQuery, just remember the last loop item and print it once a new submenu is shown in this linehttps://github.com/concrete5/concrete5/blob/master/web/concrete/bloc...
Thanks for the comment Remo! That helps a lot. I guess my question is how would I go about "remembering" the list item and print? Is the php for that?
I would rather not hard-code it. I'm hoping there is a way I can grab that automatically.
Thanks in advance!
I would rather not hard-code it. I'm hoping there is a way I can grab that automatically.
Thanks in advance!
sorry, I thought you've a developer. Yes, you've got to put that logic in the PHP code. No need to hard code, but requires PHP knowledge. Currently don't have time to write that for you, got to finish some customer projects, sorry!
ok thanks!