Zikula: A Flexible Open Source Content Management System
home | forum | contact us

Dizkus

Goto page: 1 - 2 [+1]

Bottom
Setting Active Links to a Nav bar
  • Posted: 03.08.2007, 00:39
     
    AmmoDump
    rank:
    Professional 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
  • Posted: 03.08.2007, 01:48
     
    Jusuff
    rank:
    Helper 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
  • Posted: 03.08.2007, 13:56
     
    rank:
    Moderator 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
  • Posted: 03.08.2007, 19:19
     
    AmmoDump
    rank:
    Professional 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 icon_rolleyes


    --
    David Pahl
    Zikula Support Team
  • Posted: 03.08.2007, 21:00
     
    rank:
    Moderator Moderator
    registered:
     March 2002
    Status:
    offline
    last visit:
    26.08.08
    Posts:
    7720

    AmmoDump

    Seems, I forgot it though icon_rolleyes


    Consider this a gentle hint then icon_wink

    -Mark
  • Posted: 03.08.2007, 22:26
     
    AmmoDump
    rank:
    Professional 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
  • Posted: 14.08.2007, 10:19
     
    AmmoDump
    rank:
    Professional 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
  • Posted: 23.01.2008, 19:16
     
    DavidJ
    rank:
    Softmore 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 use

    Code

    <!--[if $module == 'content']-->
    all the content links are shown as active. How do I show the different pids in the above code to only show one active link ?



    --
    David
  • Posted: 23.01.2008, 19:21
     
    Herr.Vorragend
    rank:
    Helper 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
  • Posted: 23.01.2008, 19:44
     
    DavidJ
    rank:
    Softmore 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 place

    Code

    <!--[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
  • Posted: 23.01.2008, 19:58
     
    Herr.Vorragend
    rank:
    Helper 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
  • Posted: 23.01.2008, 20:32
     
    nestormateo
    rank:
    Professional 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
  • Posted: 23.01.2008, 22:05
     
    DavidJ
    rank:
    Softmore 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
  • Posted: 16.04.2008, 01:34
     
    jaenosjelantru
    rank:
    Helper 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 ]
  • Posted: 16.04.2008, 02:11
     
    AmmoDump
    rank:
    Professional 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

Goto page: 1 - 2 [+1]

Main Menu

Extensions Database

Documentation

Development

Login

Donate to Zikula