Jump to content

Add string to MarkupSimpleNavigation list_tpl


opalepatrick
 Share

Recommended Posts

I am trying to work out how to add a string to the list tpl in MarkupSimpleNavigation so that I get something like

<li data-magellan-arrival="about">

I could add it to list_tpl 

<li data-magellan-arrival="{title}"> 

but unfortunately {title} is not interpreted as in the href

Any ideas? Appreciated.

Link to comment
Share on other sites

There's no real support for placeholder parsing in the list_tpl, only on the item_tpl.

The list_tpl has the %s that will get replaced with a class="..." string. There's a hookable method that is only for the css class string to hook into and add custom classes. So it's practically possible to use that with a little trick to add a string and would look like this:

$menu = $modules->MarkupSimpleNavigation;

$menu->addHookAfter("getListClass", null, function($event){
    $class = $event->arguments("class");
    $child = $event->arguments("page");
    $event->return = $class . '" data-attr="' . $child->title; // closing " will get added later
});

echo $menu->render($options);
  • Like 2
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...