Nov 21, 2008, 07:34 AM *
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  
Pages: [1]   Go Down
  Print  
Author Topic: Tree Javascript Menu (like the manager document tree)  (Read 2678 times)
0 Members and 1 Guest are viewing this topic.
bunk58
Committed to MODx
*****
Posts: 984


David Bunker


WWW
« on: May 24, 2008, 11:32 AM »

Someone on the forum asked about a js tree menu like in the Manager document tree and I remembered I'd done one previously.
It doesn't use the excellent Wayfinder and offers limited features, but maybe of use to some.
See it in action on my sandbox.
The zip has instructions, it's very straightforward to install.

* dtree.zip (12.76 KB - downloaded 209 times.)
« Last Edit: May 24, 2008, 01:04 PM by bunk58 » Logged

MotSmart
MODx RTL Guru.
Moderators
*
Posts: 848



WWW
« Reply #1 on: May 25, 2008, 02:14 AM »

Cool !, Thanks for sharing  Smiley
Logged

[Search] [Add-ons] | [MODx Lovers Don't miss this link!]
[Documentation] [Wiki]
[Persian support forum]
[RoadMap] [SVN] [RTL SVN Branch] [Development] [Trac] [FishEye+Crucible] [Confluence] | [My Google Code]
[برای دسترسی به راهنمای فارسی به  » وبگاه مادایکس فارسی « و یا به » انجمنهای پشتیبانی فارسی مادایکس « مراجعه کنید]
A Person is Either your Brother in Faith or Your Equal in Humanity. - Imam Ali.  # Discover Islam. | # Discover Middle East @ PressTV.
snow889
Jr. Member
*
Posts: 40


WWW
« Reply #2 on: Jul 11, 2008, 09:36 AM »

wow! very nice one!
But i have a question! Wink. Im not in Javascript very much so i cant do it myself......
I wonder if its possible to open the menu tree without clicking on the "+" sing. I would prefer if the document tree would open by just clicking on the container...
Thanx for reply!
zven
 
Logged

snow889
Jr. Member
*
Posts: 40


WWW
« Reply #3 on: Jul 11, 2008, 09:56 AM »

another question... Wink
How are the elements of the menu sorted? Seems like they are in a weired order...
greez
zven
Logged

bunk58
Committed to MODx
*****
Posts: 984


David Bunker


WWW
« Reply #4 on: Jul 11, 2008, 11:10 AM »

The order of the menu is set in the snippet as Menu Index, Ascending, but could be changed to whatever you want.
Not sure about opening on clicking the doc/folder rather than the + sign, I'll have a look at the JavaScript and report back.
Logged

snow889
Jr. Member
*
Posts: 40


WWW
« Reply #5 on: Jul 16, 2008, 05:31 AM »

thanx - the menu is working flawlessly - but has anyone an idea how to open the menu just by clicking on the link and not on the plus sign?
Logged

bunk58
Committed to MODx
*****
Posts: 984


David Bunker


WWW
« Reply #6 on: Jul 16, 2008, 08:57 AM »

Do you mean clicking on the folder icon to open the sub menu?
You couldn't click on the link to open the sub menu because the link is to open the parent page.
Logged

snow889
Jr. Member
*
Posts: 40


WWW
« Reply #7 on: Jul 16, 2008, 09:01 AM »

Jeah i want to click on the link to open the menu and the document which is clicked... is this not possible?

Logged

bunk58
Committed to MODx
*****
Posts: 984


David Bunker


WWW
« Reply #8 on: Jul 16, 2008, 09:30 AM »

I don't think it's possible with this JavaScript.
The closest I can get is by setting
 
Code:
useCookies: true,
on line 36 of the dtree.js file, which means when you've clicked the + sign and then clicked through  to a sub page the sub menu stays open.
Logged

ganeshXL
Testers
*
Posts: 1,501



WWW
« Reply #9 on: Oct 11, 2008, 02:47 PM »

It would be good to output a regular non-JS inside <noscript> for search machines etc... e.g.

Code:
<?php
/* Simple version of the tree type javascript menu by bunk 58 (David Bunker) 24/05/08 */
$siteName = $modx->config['site_name'];

$nojsOutput = '<noscript>';

$jsOutput = '';
$jsOutput .= '<script type="text/javascript">
<!--
d = new dTree(\'d\');
d.add(0,-1,\'Your Menu\');'
;
$result = mysql_query('SELECT * FROM `modx_site_content` WHERE `published`="1" AND `hidemenu`="0" AND `deleted`="0" ORDER BY `menuindex` ASC ');
while(
$row = mysql_fetch_array($result)) {
$jsOutput .= 'd.add( '. $row['id'] . ' , '. $row['parent'] . ' , \''. $row['pagetitle'] . '\', \'[~'. $row['id'] . '~]\');'."\n";
$url = $modx->makeUrl($row['id']);
$nojsOutput .= "<a href='$url'>{$row['pagetitle']}</a><br />";
}
$jsOutput .= '
document.write(d);
//-->
</script>'
;

$nojsOutput .= '</noscript>';
return (
$jsOutput . "\n" . $nojsOutput);
?>


(untested)

or, well, do the noscript part simply with Wayfinder...
Logged
Pages: [1]   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!