Dr. Scotty Delicious
Coding Team

Posts: 1,172
Dr. of Fine Pirate Arts
|
 |
« on: Oct 12, 2005, 07:24 PM » |
|
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 // jaredc@honeydewdesign.com // // 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
|
|
|
|
|
Logged
|
We pillage, we plunder, we rifle and loot. Drink up me 'earties, Yo Ho! We kidnap and ravage and don't give a hoot. Drink up me 'earties, Yo Ho! Yo Ho, Yo Ho! A pirate's life for me.
|
|
|
sottwell
Documentation Team

Posts: 8,170
|
 |
« Reply #1 on: Oct 12, 2005, 07:56 PM » |
|
Line 34: while ( ($pageInfo = $etomite->getPageInfo($sectionId,0,'parent,hidemenu')) && ($pageInfo['parent'] != $node ) && ($pageInfo['hidemenu'] == '0')) {
|
|
|
|
|
Logged
|
|
|
|
Dr. Scotty Delicious
Coding Team

Posts: 1,172
Dr. of Fine Pirate Arts
|
 |
« Reply #2 on: Oct 12, 2005, 08:07 PM » |
|
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
|
|
|
|
|
Logged
|
We pillage, we plunder, we rifle and loot. Drink up me 'earties, Yo Ho! We kidnap and ravage and don't give a hoot. Drink up me 'earties, Yo Ho! Yo Ho, Yo Ho! A pirate's life for me.
|
|
|
sottwell
Documentation Team

Posts: 8,170
|
 |
« Reply #3 on: Oct 12, 2005, 08:16 PM » |
|
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>";
|
|
|
|
|
Logged
|
|
|
|
sottwell
Documentation Team

Posts: 8,170
|
 |
« Reply #4 on: Oct 12, 2005, 08:18 PM » |
|
No no no no...it's the line 42 we need to look at. $globalKids.
|
|
|
|
|
Logged
|
|
|
|
Dr. Scotty Delicious
Coding Team

Posts: 1,172
Dr. of Fine Pirate Arts
|
 |
« Reply #5 on: Oct 12, 2005, 08:24 PM » |
|
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
|
|
|
|
|
Logged
|
We pillage, we plunder, we rifle and loot. Drink up me 'earties, Yo Ho! We kidnap and ravage and don't give a hoot. Drink up me 'earties, Yo Ho! Yo Ho, Yo Ho! A pirate's life for me.
|
|
|
sottwell
Documentation Team

Posts: 8,170
|
 |
« Reply #6 on: Oct 12, 2005, 08:26 PM » |
|
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.
|
|
|
|
« Last Edit: Oct 12, 2005, 08:32 PM by sottwell »
|
Logged
|
|
|
|
sottwell
Documentation Team

Posts: 8,170
|
 |
« Reply #7 on: Oct 12, 2005, 08:30 PM » |
|
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.
|
|
|
|
|
Logged
|
|
|
|
Dr. Scotty Delicious
Coding Team

Posts: 1,172
Dr. of Fine Pirate Arts
|
 |
« Reply #8 on: Oct 12, 2005, 08:43 PM » |
|
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
|
|
|
|
|
Logged
|
We pillage, we plunder, we rifle and loot. Drink up me 'earties, Yo Ho! We kidnap and ravage and don't give a hoot. Drink up me 'earties, Yo Ho! Yo Ho, Yo Ho! A pirate's life for me.
|
|
|
sottwell
Documentation Team

Posts: 8,170
|
 |
« Reply #9 on: Oct 12, 2005, 09:12 PM » |
|
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.
|
|
|
|
|
Logged
|
|
|
|
sottwell
Documentation Team

Posts: 8,170
|
 |
« Reply #10 on: Oct 12, 2005, 09:18 PM » |
|
Here's one that'll even sweep the floor, I think
|
|
|
|
Logged
|
|
|
|
Mark
Coding Team

Posts: 3,247
Ditto Developer
|
 |
« Reply #11 on: Oct 12, 2005, 09:21 PM » |
|
Isn't that the replacement for the menubuilder snippet which will be included in TP3.3? 
|
|
|
|
|
Logged
|
|
|
|
sottwell
Documentation Team

Posts: 8,170
|
 |
« Reply #12 on: Oct 12, 2005, 09:30 PM » |
|
Could be. I've got 38 snippet in my snippet collection now. My collections aren't too particular about where they get their content. I haven't used it, I'm still comfortable with ListMenuX.
|
|
|
|
|
Logged
|
|
|
|
jaredc
Coding Team

Posts: 290
|
 |
« Reply #13 on: Jan 05, 2006, 02:04 PM » |
|
0.9a ReleaseNew(er) and improved!OK, Dimmy arm twisted me (not really  ) in to mutilating this snippet to do some funky stuff. I reckon it's best to let others enjoy the fruits of my labor as well. For those who have been playing along and have been using the ol' Etomite version of ListGlobal, here is my changelog of what is new in version 0.9a (from the previous 0.6e and 0.6f versions): ** 0.9a ** - Added classes so every section is now classed as one of 10 classes which indicate if it is active, before or after the active, the first or last item, or whether there are no active sections at all (such as in the case of a search results page) - Also updated the version number to reflect matching compatibility with MODx - Switched $etomite object references to $modx - Accounted for MODx ability to hide options from the menu (hidemenu) - Added ability to define what to use as the tooltip text - Menu title uses "menutitle" if available or else defaults to "pagetitle"
|
|
|
« Last Edit: Jan 05, 2006, 02:08 PM by jaredc »
|
Logged
|
Standard Disclaimer I could be totally wrong.
|
|
|
Dimmy
Testers

Posts: 1,827
Я не говорю по-русски 私は日本語を話さない
|
 |
« Reply #14 on: Jan 05, 2006, 02:11 PM » |
|
Go Jared your the best Your the best!
Thank Jared for taking the time to change this script for my needs (and for the rest of the comunity) this gives MODx so mutch more potential for making funky menu items (If I want to I could have all the items a diff look YEAH)
Nice work!
Dimitri
|
|
|
|
|
Logged
|
|
|
|
|