Dec 04, 2008, 12:25 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
Search via SMF or Google: modx forums all of modxcms.com web
  MODxCMS.com   Forums   Help Login Register  
News:Donate to MODx: Donations
Pages: [1] 2   Go Down
  Print  
Author Topic: ListGlobal [snippet]  (Read 10492 times)
0 Members and 1 Guest are viewing this topic.
Dr. Scotty Delicious
Coding Team
*
Posts: 1,172


Dr. of Fine Pirate Arts


WWW
« 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.

Code:
// ------------------------
// 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



WWW
« Reply #1 on: Oct 12, 2005, 07:56 PM »

Line 34:
Code:
while ( ($pageInfo = $etomite->getPageInfo($sectionId,0,'parent,hidemenu')) && ($pageInfo['parent'] != $node ) && ($pageInfo['hidemenu'] == '0')) {
Logged

sottwell.com has moved to a lovely Solaris 10 server!
Log in username guest, password guestuser.
Templates are now becoming available at http://sottwell.com/templates.html
Dr. Scotty Delicious
Coding Team
*
Posts: 1,172


Dr. of Fine Pirate Arts


WWW
« 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



WWW
« 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:

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

sottwell.com has moved to a lovely Solaris 10 server!
Log in username guest, password guestuser.
Templates are now becoming available at http://sottwell.com/templates.html
sottwell
Documentation Team
*
Posts: 8,170



WWW
« 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

sottwell.com has moved to a lovely Solaris 10 server!
Log in username guest, password guestuser.
Templates are now becoming available at http://sottwell.com/templates.html
Dr. Scotty Delicious
Coding Team
*
Posts: 1,172


Dr. of Fine Pirate Arts


WWW
« 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



WWW
« Reply #6 on: Oct 12, 2005, 08:26 PM »

Code:
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:
Code:
getActiveChildren($node, , , 'id, pagetitle, description, parent, alias, menutitle, hidemenu')

Then after line 49,
Code:
foreach ($globalKids as $kid){
put the whole inner foreach block in an if block:
Code:
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.com has moved to a lovely Solaris 10 server!
Log in username guest, password guestuser.
Templates are now becoming available at http://sottwell.com/templates.html
sottwell
Documentation Team
*
Posts: 8,170



WWW
« 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:
Code:
[[ListMenuX?id=0&depth=2&divId=my-menu&activeLinkClass=selected]]
then you just style the .selected class in the CSS file.
Logged

sottwell.com has moved to a lovely Solaris 10 server!
Log in username guest, password guestuser.
Templates are now becoming available at http://sottwell.com/templates.html
Dr. Scotty Delicious
Coding Team
*
Posts: 1,172


Dr. of Fine Pirate Arts


WWW
« 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



WWW
« 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.com has moved to a lovely Solaris 10 server!
Log in username guest, password guestuser.
Templates are now becoming available at http://sottwell.com/templates.html
sottwell
Documentation Team
*
Posts: 8,170



WWW
« Reply #10 on: Oct 12, 2005, 09:18 PM »

Here's one that'll even sweep the floor, I think

* dropmenu.snippet.php.txt (10.35 KB - downloaded 614 times.)
Logged

sottwell.com has moved to a lovely Solaris 10 server!
Log in username guest, password guestuser.
Templates are now becoming available at http://sottwell.com/templates.html
Mark
Coding Team
*
Posts: 3,247


Ditto Developer


WWW
« 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?  Grin
Logged

sottwell
Documentation Team
*
Posts: 8,170



WWW
« 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

sottwell.com has moved to a lovely Solaris 10 server!
Log in username guest, password guestuser.
Templates are now becoming available at http://sottwell.com/templates.html
jaredc
Coding Team
*
Posts: 290



« Reply #13 on: Jan 05, 2006, 02:04 PM »

0.9a Release
New(er) and improved!

OK, Dimmy arm twisted me (not really  Wink) 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):

Quote from: My changelog thingy
** 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"

* ListGlobal0_9_a.txt (5.26 KB - downloaded 715 times.)
« Last Edit: Jan 05, 2006, 02:08 PM by jaredc » Logged

Standard Disclaimer
I could be totally wrong.
Dimmy
Testers
*
Posts: 1,827


Я не говорю по-русски 私は日本語を話さない


WWW
« 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

"They say if you play a Microsoft CD backwards, you hear satanic messages. That's nothing, because if you play it forwards, it installs Windows."
Nederlands beste portal voor pda en mobiel internet
Pages: [1] 2   Go Up
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP

Copyright © 2005-2008 MODxCMS, All rights reserved. Contact Us
Styles by ziworks.com

Powered by SMF 1.1.4 | SMF © 2005, Simple Machines LLC

Valid XHTML 1.0! Valid CSS!