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!!

jlines41
View Replies:
Remo replied on at Permalink Reply
Remo
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.
jlines41 replied on at Permalink Reply
jlines41
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.
Pluto replied on at Permalink Reply
Pluto
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
jlines41 replied on at Permalink Reply
jlines41
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.
Remo replied on at Permalink Reply
Remo
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...
jlines41 replied on at Permalink Reply
jlines41
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!
Remo replied on at Permalink Reply
Remo
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!
jlines41 replied on at Permalink Reply
jlines41
ok thanks!