We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 15987
    • 786 Posts
    If you can show me what you document tree looks like in modx and which documents you are trying to display I can help you try and get it working.
      • 13219
      • 19 Posts
      Hello and sorry for the late reply, I was out for a while...
      I am listing the document tree below, let me know if you need that in a different format.

      domain.com
      index.php (id 12)
      -gallery (folder)
      index.php (id 16)
      -studios(folder)
      index.php (id 32)
      -artists(folder)
      index.php (id 52)
      -custom(folder)
      index.php (id 11)

      On my main Menu I want to list ID’s 12, 16, 32, 52, 11
      thank you!
        • 13219
        • 19 Posts
        I suppose I could just make a junk like below and call it instead of wayfinder, if there is no way around it
        <a href="[~12~]">$19.95</a>&nbsp;&nbsp;
        <a href="[~16~]">$19.95</a>&nbsp;&nbsp;
        <a href="[~32~]">$19.95</a>&nbsp;&nbsp;
        <a href="[~52~]">$19.95</a>&nbsp;&nbsp;
        <a href="[~11~]">$19.95</a>&nbsp;&nbsp;
          • 15987
          • 786 Posts
          I think that may be the best way to go. I’m not sure you can get the output you want due to the nesting that the output uses.
            • 7231
            • 4,205 Posts
            I always thought that a Menu Builder snippet that would work independent of the document tree would be cool. I guess this can be done by hand as the example above but this will not benefit from the ’intelligence’ of smart links that know when they are active.
              [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

              Something is happening here, but you don&#39;t know what it is.
              Do you, Mr. Jones? - [bob dylan]
              • 27708 MODX Staff
              • 2,502 Posts
              You could write a small snippet that could check the id of the current doc to see if the nav matches and return a class of active to the li or a elements.

              I used to do this for all my sites before I started using MODx. Basically I would create an array and a loop that would check match on the document (in that case by a site_section variable) and return the class in the output and it worked very easily. Here is an example:

              <div id="menu">
              <ul id="navigation">
              <?php 
              	
              //This array defines the links and the site_section names for the links list created by the foreach
              
              $links = array(''=>'home','buy/'=>'buyers', 'sell/'=>'sellers','listings/'=>'listings','team/'=>'Our Team','blog/'=>'Blog','contact/'=>'contact');
              	
              // This foreach statement creates a menu with as many links as $values in the array and converts text to first letter uppercase
              
              foreach ($links as $key => $value){
              		echo '<li';
              		if ($site_section == $value)
              		{ echo ' class="active"'; } 
              		else { echo '';} echo '><a'; 
              		if ($site_section == $value){ echo ' id="current"'; } 
              		else { echo '';} echo ' href="'.SITE_TOP_PATH.$key.'">'.ucfirst($value).'</a></li>'."\n";}?>
              </ul>
              </div>
              



              You would have to fix the array so that the value was the id and that the match was on the document id but it would work just the same.

              However, you may actually be able to do this even easier using PHx’s advanced syntax something like:
              <a href="[~12~]" [+phx:if=`[*id*]`:is=`12`:then=` {{activeClass}} `:else=``+]>$19.95</a>
              <a href="[~16~]" [+phx:if=`[*id*]`:is=`16`:then=` {{activeClass}} `:else=``+]>$19.95</a>
              <a href="[~32~]" [+phx:if=`[*id*]`:is=`32`:then=` {{activeClass}} `:else=``+]>$19.95</a>
              <a href="[~52~]" [+phx:if=`[*id*]`:is=`52`:then=` {{activeClass}} `:else=``+]>$19.95</a>
              <a href="[~11~]" [+phx:if=`[*id*]`:is=`11`:then=` {{activeClass}} `:else=``+]>$19.95</a>


              You would just place the following into a new chunk "{{activeClass}}:
              class="active"


              In addition, someone who knows more about snippets MODx would likely be able to write this simpler by merely checking to see if the current document was equal to the url id.

              Hope this helps you move in the right direction.

              Cheers,

              Jay
                Author of zero books. Formerly of many strange things. Pairs well with meats. Conversations are magical experiences. He's dangerous around code but a markup magician. Blog ✦ Twitter ✦ LinkedIn ✦ GitHub
                • 7231
                • 4,205 Posts
                I need to take a better look at PHx. I think that there is a snippet that will include an active class, I remember seeing this a while back but could not find it anymore.
                  [font=Verdana]Shane Sponagle | [wiki] Snippet Call Anatomy | MODx Developer Blog | [nettuts] Working With a Content Management Framework: MODx

                  Something is happening here, but you don&#39;t know what it is.
                  Do you, Mr. Jones? - [bob dylan]
                  • 27708 MODX Staff
                  • 2,502 Posts
                  I just go onto using PHx and it is a really amazing little plugin that adds real neat capabilities. I am sure you could quite easily use the php code I wrote as the basis for as snippet as it should be easy to modify it to use the id/current id match evaluation that is in it.

                  I would think it should look something like this:

                  <?php 
                  //Create Variable for the current document id
                  
                  $curID = $modx->documentObject['id'];
                  
                  //This array defines the links and the site_section names for the links list created by the foreach
                  
                  $links = array(''=>'home','buy/'=>'buyers', 'sell/'=>'sellers','listings/'=>'listings','team/'=>'Our Team','blog/'=>'Blog','contact/'=>'contact');
                  	
                  // This foreach statement creates a menu with as many links as $values in the array and converts text to first letter uppercase
                  
                  foreach ($links as $key => $value){
                  		echo '<li';
                  		if ($curID == $value)
                  		{ echo ' class="active"'; } 
                  		else { echo '';} echo '><a'; 
                  		if ($curID == $value){ echo ' id="current"'; } 
                  		else { echo '';} echo ' href="[(base_url)]'.$key.'">'.$value.'</a></li>'."\n";}?>
                    Author of zero books. Formerly of many strange things. Pairs well with meats. Conversations are magical experiences. He's dangerous around code but a markup magician. Blog ✦ Twitter ✦ LinkedIn ✦ GitHub
                    • 13219
                    • 19 Posts
                    ok, I guess this is the only way then, if using a structure like this. thanks!
                      • 27708 MODX Staff
                      • 2,502 Posts
                      I wouldn’t say this is the only way and I am no real great php guy but it worked for me. I would think that this could be turned into a class and called on an array and work a little more cleanly but I am barely learning to stand up on my feet as far as Object Oriented Programming is concerned.

                      All the best,

                      Jay
                        Author of zero books. Formerly of many strange things. Pairs well with meats. Conversations are magical experiences. He's dangerous around code but a markup magician. Blog ✦ Twitter ✦ LinkedIn ✦ GitHub