- Moderated by:
- Support Team
-
- rank:
-
Professional
- registered:
- December 2003
- Status:
- offline
- last visit:
- 21.11.08
- Posts:
- 2975
Currently it is slipping my mind...
What I am trying to do is get the module name assign a variable to it, check it against link name, to assign the active link...
Any Ideas?
--
David Pahl
Zikula Support Team -
- rank:
-
Helper
- registered:
- April 2005
- Status:
- online
- Posts:
- 163
Try this - at the top of template:
Code
<!--[pnvarcleanfrominput name='module' assign='thismodname']-->
Then you'll have to check for every link:
Code
<!--[if $thismodname == 'somemodname']-->class='selected'<!--[/if]-->
--
Polish Zikula Team
Bianor Works - my Zikula works on CoZi -
- rank:
-
Moderator
- registered:
- March 2002
- Status:
- offline
- last visit:
- 26.08.08
- Posts:
- 7720
Xanthia already assigns the top-level module name as a template variable named $module.
To see what variables are available in any template add the pndebug tag to that template. A popup will appear (if your a site admin) containing all available template variables.
-Mark -
- rank:
-
Professional
- registered:
- December 2003
- Status:
- offline
- last visit:
- 21.11.08
- Posts:
- 2975
markwest
To see what variables are available in any template add the pndebug tag to that template. A popup will appear (if your a site admin) containing all available template variables.
And of course, I knew this... Seems, I forgot it though
--
David Pahl
Zikula Support Team -
- rank:
-
Professional
- registered:
- December 2003
- Status:
- offline
- last visit:
- 21.11.08
- Posts:
- 2975
Perfect!
For anyone interested in the code... Also, to set the home page use $mainpage
Thanks Guys!
Code
<div id="menu">
<ul>
<!--[if $module == $mainpage]-->
<li class="active">
<!--[else]-->
<li>
<!--[/if]-->
<a href="index.php">Home</a></li>
<!--[if $module == 'mediashare']-->
<li class="active">
<!--[else]-->
<li>
<!--[/if]-->
<a href="index.php?&name=Mediashare">Gallery</a></li>
<!--[if $module == 'pnForum']-->
<li class="active">
<!--[else]-->
<li>
<!--[/if]-->
<a href="index.php?&name=pnForum">Message Board</a></li>
edited by: AmmoDump, Aug 14, 2007 - 12:05 AM
--
David Pahl
Zikula Support Team -
- rank:
-
Professional
- registered:
- December 2003
- Status:
- offline
- last visit:
- 21.11.08
- Posts:
- 2975
Or... I love this:
Code
<body id="<!--[$module]-->">
<ul>
<!--[if $module == $mainpage]-->
<li class="active">
<!--[else]-->
<li>
<!--[/if]-->
<a href="index.php">Home</a></li>
<a href="index.php?&name=Mediashare" class="mediashare">Gallery</a></li>
<a href="index.php?&name=pnForum" class="pnForum">Message Board</a></li>
Now in the CSS we add the following...
Code
#mediashare .mediashare, #pnForum .pnForum {
/* your active style */
}
Thus we eliminate the conditional statements, save the main page. The styles need to be added, but I think this is a cleaner solution.
edited by: AmmoDump, Aug 14, 2007 - 12:21 AM
--
David Pahl
Zikula Support Team -
- rank:
-
Softmore
- registered:
- January 2008
- Status:
- offline
- last visit:
- 09.09.08
- Posts:
- 75
I would welcome some advice on the following:
I am using the Andreas08 theme in 0.8.0.0-RC2
The nav bar consists of a number of seperate links to individual pages in the new content module, for example one link will go to Content&func=view&pid=1 and another to Content&func=view&pid=2.
If I useall the content links are shown as active. How do I show the different pids in the above code to only show one active link ?Code
<!--[if $module == 'content']-->
--
David
-
- rank:
-
Helper
- registered:
- July 2004
- Status:
- offline
- last visit:
- 17.11.08
- Posts:
- 109
Same procedure:
Code
<!--[pnvarcleanfrominput name='pid' assign='pid']-->
and so on....
--
Carsten-volmer.de
Saga-Treff.de -
- rank:
-
Softmore
- registered:
- January 2008
- Status:
- offline
- last visit:
- 09.09.08
- Posts:
- 75
Herr.Vorragend many thanks for your quick reply it is appreciated.
A bit new to this so I am still a bit confused so where in my theme template do I placeCode
<!--[pnvarcleanfrominput name='pid' assign='pid']-->
This is from my existing theme template:
Code
<div id="theme_navigation_bar">
<ul>
<!--[if $loggedin eq true]-->
<li class="selected"><a href="<!--[pngetbaseurl]-->">Home</a></li>
<li<!--[if $module eq 'content']--> class="selected"<!--[/if]-->><a href="index.php?module=Content&func=view&pid=1">Trustees</a></li>
<li<!--[if $module eq 'content']--> class="selected"<!--[/if]-->><a href="index.php?module=Content&func=view&pid=2">Location</a></li>
<li> <a href="index.php?module=Pagesetter%20Calendar&func=classic&tid=1">Events</a></li>
<li<!--[if $module eq 'mediashare']--> class="selected"<!--[/if]-->><a href="index.php?module=mediashare&type=edit&func=view&aid=1">Gallery</a></li>
<li<!--[if $module eq 'content']--> class="selected"<!--[/if]-->><a href="index.php?module=Content&func=view&pid=3">History</a></li>
<li<!--[if $module eq 'Search']--> class="selected"<!--[/if]-->><a href="<!--[pnmodurl modname=Search]-->"><!--[pnml name="_SEARCH"]--></a></li>
<li<!--[if $module eq 'Profile']--> class="selected"<!--[/if]-->><a href="<!--[pnmodurl modname=Profile]-->"><!--[pnml name="_YOURACCOUNT"]--></a></li>
<li<!--[if $module eq 'Admin']--> class="selected"<!--[/if]-->><a href="index.php?module=Admin&type=admin&func=adminpanel">Admin</a></li>
<!--[else]-->
--
David
-
- rank:
-
Helper
- registered:
- July 2004
- Status:
- offline
- last visit:
- 17.11.08
- Posts:
- 109
Somewhere at the top of the theme/template:
Code
<!--[pnvarcleanfrominput name="module" assign=module]-->
<!--[pnvarcleanfrominput name="pid" assign=pid]-->
Now you have to variables: $module and $pid.
Code
...
<li <!--[if $module eq "content" && $pid="1" ]--> class="selected"<!--[/if]-->>
<a href="<!--[pnmodurl modname="Content" type="user" func="view" pid="1"]-->">
Trustees
</a>
</li>
...
edited by: Herr.Vorragend, Jan 23, 2008 - 04:00 PM
--
Carsten-volmer.de
Saga-Treff.de -
- rank:
-
Professional
- registered:
- September 2006
- Status:
- online
- Posts:
- 1451
I preffer to manage this with a simple plugin.
An example of the think i do is in my alpha blanktheme (available here).
--
- Mateo T. -
Mis principios... son mis fines -
- rank:
-
Softmore
- registered:
- January 2008
- Status:
- offline
- last visit:
- 09.09.08
- Posts:
- 75
Thanks Herr.Vorragend. The template variable named $module was already assigned so I only needed to assign the $pid variable and all now works as it should.
Mateo thanks very much for your comments. I have downloaded a copy of your blank theme and will try it out.
--
David
-
- rank:
-
Helper
- registered:
- March 2005
- Status:
- online
- Posts:
- 360
This is an excellent guide on setting active links. I would add that Smarty doesn't seem to like = but rather eq.
So I used the following:
Code
<div id="theme_navigation_bar">
<ul>
<li><a href="index.php"><!--[pnml name="_NEXUS_HOME"]--></a></li>
<li<!--[if $module eq 'About Us']--> class="selected"<!--[/if]-->><a href="<!--[pnmodurl modname=About]-->">About Us</a></li>
<li<!--[if $module eq 'htmlpages' && $pid eq '1' ]--> class="selected"<!--[/if]-->><a href="<!--[pnmodurl modname=Staff]-->">Staff</a></li>
<li<!--[if $module eq 'crpCalendar']--> class="selected"<!--[/if]-->><a href="<!--[pnmodurl modname=Events]-->">Events</a></li>
<li<!--[if $module eq 'htmlpages' && $pid eq '5' ]--> class="selected"<!--[/if]-->><a href="<!--[pnmodurl modname=Services]-->">Services</a></li>
<li<!--[if $module eq 'News']--> class="selected"<!--[/if]-->><a href="<!--[pnmodurl modname=News]-->">Newsletter</a></li>
<li<!--[if $module eq 'Search']--> class="selected"<!--[/if]-->><a href="<!--[pnmodurl modname=Search]-->"><!--[pnml name="_SEARCH"]--></a></li>
</ul>
</div>
--
[ stevencopley.com ] -
- rank:
-
Professional
- registered:
- December 2003
- Status:
- offline
- last visit:
- 21.11.08
- Posts:
- 2975
Smarty likes = signs just fine... how else would you assign a variable?
Code
<!--[something this=that]-->
== are for comparing
Code
<!--[if this == that]-->
--
David Pahl
Zikula Support Team
