Fork me on GitHub

voododolly - navbar - template override?  Bottom

  • First of all, thanks for the support you're giving to a old-newbie like me! icon_smile

    Before asking my questions, I'd like to to understand if my voodoodolly discussions fit better in this forum or in " Extensions and Distributions Support"... or is it the same?

    anyway, things proceed, slowly, but constantly.
    Now it's time to customize the navbar, leaving out some items and inserting some other, e.g. a direct "log out" link...

    I've seen the navbar menu items in the "master.htm" file in themes/voododolly/templates, and first thing I thought was about overriding it, without directly modifying it...

    but template overrides are in a "module" child subdir, and it's about... well... modules! icon_smile
    and nav bar doesn't seem to be a module.

    Does this mean that overriding the navigation bar is not possible?
    (and that I'll have to remember to save a copy of the modified main.htm file, if I don't want lose my changes after an upgrade?)

    thanks
    enrico

  • 1. You could make a plugin like below and put it in voodololly/plugins as function.userlinks.php.
    After that you can call the plugin from master.htm like

    Code

    <!--[userlinks]-->

    instead of the hard coded ul ... /ul part. Your menu is then seperate from master.htm. In the BlankTheme project we also use a plugin for the userlinks. It is a bit more extended to also support a current selection and so on, but basically the same.

    the plugin (not tested BTW):

    Code

    <?php
    function smarty_function_userlinks($params, &$smarty)
    {
        extract($params);
        unset($params);

        $output = '<ul>';
        $output .=   '<li class="selected"><a href="<!--[pngetbaseurl]-->">Home</a></li>';
        $output .=   '<li><a href="' . pnModURL('News', 'user', 'new') . '">_SUBMITNEWS</a></li>';
        $output .=   '<li><a href="' . pnModURL('Downloads', 'user', 'new') . '">_DOWNLOADS</a></li>';
        $output .=   '<li><a href="' . pnModURL('Web_Links') . '">_WEB_LINKS</a></li>';
        $output .=   '<li><a href="' . pnModURL('Search') . '">_SEARCH</a></li>';
        $output .=   '<li><a href="' . pnModURL('Profile') . '">_YOURACCOUNT</a></li>';
        $output .= '</ul>';

        return $output;
    }



    2. Another option could also be to make a new blockposition on the top and put an extmenu block there with a horizontal styling. You can then configure your menu as any regular menu taking into account for example permissions and multi language things etc.
    Check out the already ready made extmenu designs (package under downloads) and an article about menus for extmenu and menutree here
    I use an extmenu (as example) on my personal page erikspaan.nl. There you see a menutree menu op the top and below that an extmenu menu. Advantage of the extmenu's is that they already have code for the currently selected page in there. As you can see on my homepage.

    --
    campertoday.nl, Module development, Dutch Zikula Community
  • weird...
    just to see if it works, I inverted two already set items in voodoodolly/templates/master.htm

    from

    Code

    <div class="navbar" id="nav">
        <ul>
          <li class="selected"><a href="<!--[pngetbaseurl]-->">Home</a></li>
          <li><a href="<!--[pnmodurl modname=News func=new]-->"><!--[pnml name="_SUBMITNEWS"]--></a></li>
          <li><a href="<!--[pnmodurl modname=Downloads]-->"><!--[pnml name="_DOWNLOADS"]--></a></li>
          <li><a href="<!--[pnmodurl modname=Web_Links]-->"><!--[pnml name="_WEB_LINKS"]--></a></li>
          <li><a href="<!--[pnmodurl modname=Search]-->"><!--[pnml name="_SEARCH"]--></a></li>
          <li><a href="<!--[pnmodurl modname=Profile]-->"><!--[pnml name="_YOURACCOUNT"]--></a></li>
         
        </ul>
      </div>



    to

    Code

    <div class="navbar" id="nav">
        <ul>
          <li class="selected"><a href="<!--[pngetbaseurl]-->">Home</a></li>
          <li><a href="<!--[pnmodurl modname=News func=new]-->"><!--[pnml name="_SUBMITNEWS"]--></a></li>
          <li><a href="<!--[pnmodurl modname=Downloads]-->"><!--[pnml name="_DOWNLOADS"]--></a></li>
          <li><a href="<!--[pnmodurl modname=Web_Links]-->"><!--[pnml name="_WEB_LINKS"]--></a></li>
          <li><a href="<!--[pnmodurl modname=Profile]-->"><!--[pnml name="_YOURACCOUNT"]--></a></li>
          <li><a href="<!--[pnmodurl modname=Search]-->"><!--[pnml name="_SEARCH"]--></a></li>
        </ul>
      </div>


    (switched last two items)

    .. but after copying the new file in the website directory, nothing changes in the navbar...

    is there a way to check what "master.htm" file is in use?
    (maybe via pndebug setting? I read something about it elsewhere)
  • found!
    it's not "master.htm", but "home.htm" to be modified!
    To find it I enabled "Expose template information in comments" in pnRender Admin
    just tried and I was lucky!

    .. so what "master.htm" is for ? icon_smile
  • m7b5

    found!
    it's not "master.htm", but "home.htm" to be modified!


    ... almost!
    the change is effective only for the homepage... every other module selected displays the original navbar.
    so "home.htm" is not the correct file to modify if I want to globally change the navbar
    (although I found a way to have different navbar settings for different modules.. just in case...)

    I stop here now, quite tired... maybe a good sleep (or some guru here around) will suggest the right way tomorrow! icon_smile
  • home.htm is for the home page regardless of module chosen for the home page, master.htm is for everything else past the home page, and admin.htm is for admin output.

    That being said make sure that caching is off or you won't see the differences immediately..



    edited by: Topiatic, Sep 25, 2008 - 06:04 PM

    --
    Under Construction!
  • That's why putting the whole navbar into a plugin that you call from master.htm and home.htm is a nicer way of getting the same menu everywhere.
    You found out some of the ways of working of Xanthia themes the hard way icon_smile Did you read the pages on Theme authoring in the Wiki docs here?

    --
    campertoday.nl, Module development, Dutch Zikula Community
  • espaan

    Did you read the pages on Theme authoring in the Wiki docs here?


    I'm right now...
    And I hope I'll find also other answers to questions I yet didn't post icon_smile

    thank you
    enrico
  • espaan

    That's why putting the whole navbar into a plugin that you call from master.htm and home.htm is a nicer way of getting the same menu everywhere.
    You found out some of the ways of working of Xanthia themes the hard way icon_smile


    I done it, the nice way! icon_smile
    Now I have a working plugin inserted in both master.htm and home.htm
    so now i can modify both navbars in one place only!

    (but actually I had to modify the templates, so in case of reinstall, my changes will be overwritten anyway, right?)

    Now the next step is to change the navbar items acording with the user group...

    Again, I'd like to find the cleanest way to do it, and by now,
    it seems to me that I can insert a if-then-else block in my plugin funcion, trying to get the current user group value, then displaying the proper items (there should be some global array available with that info, or bettere some kind of GetCurrentUserGroup() function to call)
    Am I on the right path? icon_smile

    (the other thing that comes in mind is a permission setup, like you do with blocks and modules, but it seems to me a bit too much complicated..)


    BTW: I read somewhere on the forum about Zikula 2.0 compatibility with PHP5... Does it mean that current version (1.0.2) is not?
    My provider is going to upgrade to PHP5, and in case I'd better ask to stop for my account installation...

    again,
    thanks a lot for your support!
    Enrico





    edited by: m7b5, Sep 28, 2008 - 07:58 AM
  • Zikula 1 runs fine in a php5 environment.

    You can use the UserUtill:: to aquire user groups with something like this:

    Code

    Loader::loadClass('UserUtil');
        $user_groups = UserUtil::getGroupsForUser(SessionUtil::getVar('uid'))

        // if you need the group names instead of id's
        $all_groups = UserUtil::getPNGroups();
        foreach ($user_groups as $gid) {
            $user_group_names[$gid] = $all_groups[$gid]['name'];
        }


    Have a look through includes/pnobjlib/UserUtil.class.php to see what's available.



    edited by: Topiatic, Sep 28, 2008 - 10:13 AM

    --
    Under Construction!
  • Topiatic



    You can use the UserUtill:: to aquire user groups with something like this:

    Code

    Loader::loadClass('UserUtil');
        $user_groups = UserUtil::getGroupsForUser(SessionUtil::getVar('uid'))

        // if you need the group names instead of id's
        $all_groups = UserUtil::getPNGroups();
        foreach ($user_groups as $gid) {
            $user_group_names[$gid] = $all_groups[$gid]['name'];
        }





    wonderful, it works!

    I inserted the code in my plugin function, then I browse through all theuser groups array, activating when needed the related menu item.
    my only worry now is:

    the plugin function is called at every page refresh, and so is the UserUtil::getGroupsForUser and UserUtil::getPNGroups().
    Isn't this too 'heavy' ?
    (it could be done only once when session begins, or not?).





    edited by: m7b5, Sep 28, 2008 - 02:49 PM
  • I'm not sure how heavy these functions are but maybe have a look at the CookieUtil:: to set/get cookie params once you determine which nav panel to display.

    --
    Under Construction!
  • In those cases i use SessionUtil::setVar and getVar,
    but should check if the session values are deleted when login/logout,
    indispensable in this case.

    --
    - Mateo T. -
    Mis principios... son mis fines
  • Nice, I didn't realise that getVar and setVar had found a home in the SessionUtil::.

    --
    Under Construction!

This list is based on users active over the last 60 minutes.