We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 26435
    • 1,193 Posts
    ScottyDelicious Reply #1, 21 years ago
    If anyone has time, would you look at this "ListGlobal" snippet. I have been a fan of this menu system since I used Etomite, but it displays the menu items that have "show in menu" unchecked. Unfortunately, the EPG2 photo gallery snippet does not play well in an unpublished folder, so I would like to know what changes to the ListGlobal code need to be made for it to respect the option to not show in menu.

    // ------------------------
    // Snippet: ListGlobal
    // ------------------------
    // Version: 0.6e
    // Date: 2005.07.01
    // [email protected]
    //
    // Snippet for listing global list of links or sections
    // (Published pages who's parent is root). Highlight ability
    // for current section.
    
    // $node [ int ]
    // Id of what you want to consider the "root" of the site or section.
    // For instance, if you branch off several sections from the 0 root level
    // based on languages, you might want to set the language home page as
    // the root. Otherwise it will default to 0- which is the site root. It
    // will also default to 0 when 0 is the literal root. Settable in snippet
    // call with $LGlob_node:
    // [[ListGlobal?LGlob_node=7]]
       $node = 0;
       
    // STYLES
    // .LGlob_list    ul element of list
    // .LGlob_active  li of section you are in
    
    // -----------------------
    // END CONFIG
    // -----------------------
    
    // Override default node with snippet call if necessary
    $node = (isset($LGlob_node))? $LGlob_node : $node;
    
    // Determine correct node to consider parent
    $tempPageInfo = $etomite->getPageInfo($etomite->documentIdentifier,0,'parent');
    $thisParent = $tempPageInfo['parent'];
    
    // Change root node if necessary
    if ($node && !$thisParent){
      $node = 0;
    }
    
    $globalKids = $etomite->getActiveChildren($node);
    $sectionId = $etomite->documentIdentifier;
    while ( ($pageInfo = $etomite->getPageInfo($sectionId,0,'parent')) && ($pageInfo['parent'] != $node ) ) {
      $sectionId = $pageInfo['parent'];
    }
    $output = '<ul class="LGlob_list">';
    $globalCount = 0;
    foreach ($globalKids as $kid){
        $output .= '<li';
        $output .= ($kid['id']==$sectionId)? ' class="LGlob_active"' : '' ;
        $output .= '><a href="[~'.$kid['id'].'~]" ';
        $output .= 'title="'.$kid['pagetitle'].'">';
        $output .= $kid['pagetitle'].'</a></li>';
        $globalCount++;
    }
    $output .= '</ul>';
    return $output;
    


    Thank you for your time and your help

    -sD-
    scotty Delicious
      Husband, Father, Brother, Son, Programmer, Atheist, Nurse, Friend, Lover, Fighter.
      All of the above... in no specific order.


      I send pointless little messages
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      Line 34:
      while ( ($pageInfo = $etomite->getPageInfo($sectionId,0,'parent,hidemenu')) && ($pageInfo['parent'] != $node ) && ($pageInfo['hidemenu'] == '0')) {
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 26435
        • 1,193 Posts
        ScottyDelicious Reply #3, 21 years ago
        hmmm...
        No joy.  I changed the code in the ListGlobal snippet with the code you provided, but if you look at

        http://www.scottydelicious.com/modx/

        the menu items ’Gallery Admin Page’ and ’News Stories Go Here’ have been unchecked to "show in menu".

        By the way, thanks for the speedy reply!

        -sD-
        scottty Delicious
          Husband, Father, Brother, Son, Programmer, Atheist, Nurse, Friend, Lover, Fighter.
          All of the above... in no specific order.


          I send pointless little messages
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          Hm. Put a bit of code like this right after that line so you can see what’s going on:

          echo "<pre>";
          print_r($pageInfo);
          echo "</pre>";
          

            Studying MODX in the desert - http://sottwell.com
            Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
            Join the Slack Community - http://modx.org
            • 28042 ☆ A M B ☆
            • 24,524 Posts
            No no no no...it’s the line 42 we need to look at. $globalKids.
              Studying MODX in the desert - http://sottwell.com
              Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
              Join the Slack Community - http://modx.org
              • 26435
              • 1,193 Posts
              ScottyDelicious Reply #6, 21 years ago
              Well Susan,

              I wish I knew more about PHP. I did paste the last bit of code you posted directly after the first bit of code you posted. It looks like it should ’write’ something on the screen (echo ?). anyway. I did implement the snippet and I am still stuck. I am not able to see anything ’echoed’ to the screen. Maybe I am not supposed to? The reason I like this snippet so much is the "ACTIVE" page’s tab looks different. I guess it is not that important, but I like style, and I like the way that Active menu tab makes a website look!

              thanks again, and I appreciate all your effort!

              -sD-
              scotty Delicious
                Husband, Father, Brother, Son, Programmer, Atheist, Nurse, Friend, Lover, Fighter.
                All of the above... in no specific order.


                I send pointless little messages
                • 28042 ☆ A M B ☆
                • 24,524 Posts
                getActiveChildren($id=0, $sort='menuindex', $dir='ASC', $fields='id, pagetitle, description, parent, alias, menutitle')

                is the function definition. So you’ll need to do this:
                getActiveChildren($node, , , 'id, pagetitle, description, parent, alias, menutitle, hidemenu')


                Then after line 49,
                foreach ($globalKids as $kid){

                put the whole inner foreach block in an if block:
                if($kid['hidemenu'] == 0) {
                    $output .= '<li';
                    $output .= ($kid['id']==$sectionId)? ' class="LGlob_active"' : '' ;
                    $output .= '><a href="[~'.$kid['id'].'~]" ';
                    $output .= 'title="'.$kid['pagetitle'].'">';
                    $output .= $kid['pagetitle'].'</a></li>';
                    $globalCount++;
                }
                


                That should do the trick.
                  Studying MODX in the desert - http://sottwell.com
                  Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                  Join the Slack Community - http://modx.org
                  • 28042 ☆ A M B ☆
                  • 24,524 Posts
                  All the menu snippets have that "active" or "selected" or whatever you want to call it. Some of them you have to specify what you want the class called when you call the snippet. For example, ListMenuX goes like this:
                  [[ListMenuX?id=0&depth=2&divId=my-menu&activeLinkClass=selected]]
                  then you just style the .selected class in the CSS file.
                    Studying MODX in the desert - http://sottwell.com
                    Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                    Join the Slack Community - http://modx.org
                    • 26435
                    • 1,193 Posts
                    ScottyDelicious Reply #9, 21 years ago
                    You are getting sooooo close, I can almost see it.

                    The last revision still shows the unchecked show in menu pages, however.

                    Perhaps there is a better way for me to go about this.  Is there any MODx menu snippet that is capable of the "active" highlighting.  I see in the MenuBuilder code that there is a reference to the class "highLight", so i put a ".highLight" and a ".highLight a" class in my CSS, but there was no effect.  I will look into ListMenuX as you mentioned above

                    Kind regards

                    -sD-
                    scotty Delicious
                      Husband, Father, Brother, Son, Programmer, Atheist, Nurse, Friend, Lover, Fighter.
                      All of the above... in no specific order.


                      I send pointless little messages
                      • 28042 ☆ A M B ☆
                      • 24,524 Posts
                      Did you clear your cache? I just now styled the "a.selected" class for my latest use of MenuBuilder.

                      http://www.sottwell.com check out the "theo" template.
                        Studying MODX in the desert - http://sottwell.com
                        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                        Join the Slack Community - http://modx.org