Add code to current menu item

Permalink 1 user found helpful
Hi all,

I'm new to concrete5 and just started converting a HTML template to a c5 theme. The problem that i'm having is that the template requires
<span></span>
next to the <a> tag of the current menu item.

So you would get:
<a class="nav-selected nav-path-selected" href="#">Home</a><span></span>


Instead of just the link.

Anyone know how this can be achieved? Thanks in advance!

 
glockops replied on at Permalink Reply
glockops
What you want is a "Custom Template".
You can override the "view.php" file for the auto-nav block by copying the view.php file from /concrete/blocks/autonav/view.php and put it in /blocks/autonav/templates/my_custom_template_name/view.php.

Then make the changes so that the currently selected link has the <span></span> added to it.

Then while in edit mode, you can click on the autonav block and choose "Custom Template", you'll see "my_custom_template_name" in the drop-down list. Select it and you'll have your span tag added.

If you've inserted the autonav programmatically, then you "call" your custom template with
<?php
// This is after you've configured the custom template programmatically
// $varname is your variable name for the block
$varname->render('templates/my_custom_template_name/view');
?>


my_custom_template_name should be descriptive of your custom template, you cannot have spaces - use underscores instead.
jordanlev replied on at Permalink Best Answer Reply
jordanlev
I've written a detailed walk-through of how to customize the autonav template (including a better template that is much easier to work with than what's included in C5):
http://c5blog.jordanlev.com/blog/2011/12/customizing-the-autonav-te...
dstepanovic replied on at Permalink Reply
Thanks guys, it works!