function initMenus() {
$('ul.menu ul').hide();
$.each($('ul.menu'), function(){
$('#' + this.id + '.expandfirst ul:first').show();
});
$('ul.menu li a').click(
function() {
var checkElement = $(this).next();
var parent = this.parentNode.parentNode.id;
if($('#' + parent).hasClass('noaccordion')) {
$(this).next().slideToggle('normal');
return false;
}
if((checkElement.is('ul')) && (checkElement.is(':visible'))) {
if($('#' + parent).hasClass('collapsible')) {
$('#' + parent + ' ul:visible').slideUp('normal');
}
return false;
}
if((checkElement.is('ul')) && (!checkElement.is(':visible'))) {
$('#' + parent + ' ul:visible').slideUp('normal');
checkElement.slideDown('normal');
return false;
}
}
);
}
$(document).ready(function() {initMenus();});[[Wayfinder? &startId=`0` &level=`2`&outerTpl=`outerTpl`&rowTpl=`rowTpl`&innerTpl=`innerTpl` &innerRowTpl=`innerRowTpl`&parentTpl=`parentTpl`]]
<!-- Include jQuery Library --> <script type="text/javascript" src="assets/templates/tutorial/js/jquery-1.2.1.min.js"></script> <script type="text/javascript" src="assets/templates/tutorial/js/menu.js"></script>
<ul id="menu" class="menu noaccordion"> [+wf.wrapper+] </ul>
<li [+wf.classes+]><a href="[+wf.link+]">[+wf.linktext+]</a> [+wf.wrapper+] </li>
[+wf.wrapper+]
<li [+wf.classes+]><a href="[+wf.link+]" title="[+wf.title+]">[+wf.linktext+]</a> <ul id="doc_[+wf.docid+]" class="noaccordion">[+wf.wrapper+] </ul> </li>
<li [+wf.classes+]><a href="[+wf.link+]" title="[+wf.title+]">[+wf.linktext+]</a> [+wf.wrapper+]</li>
<ul id="menu3" class="menu noaccordion"> <!-- vertical menu – it's all done with the CSS -->
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>[(site_name)] | [*pagetitle*]</title> <meta http-equiv="Content-Type" content="text/html; charset=[(modx_charset)]" /> <base href="[(site_url)]"></base> <link rel="stylesheet" href="assets/js/style.css" type="text/css" media="screen" /> <script src="assets/js/jquery-1.2.1.min.js" type="text/javascript"></script> <script src="assets/js/menu.js" type="text/javascript"></script> </head> <body> <div id="wrapper"> [[Wayfinder? &startId=`0` &level=`2` &outerTpl=`jqaccoutertpl` &innerTpl=`jqaccinnertpl` &rowTpl=`jqaccrowtpl`]] <h2>[*longtitle*]</h2> [*content*] </div><!-- end wrapper --> </body> </html>
<ul id="menu1" class="menu"> <!-- outerTpl chunk--> <li> <!-- part of rowTpl chunk--> <a href="#">Weblog Tools</a> <ul> <!-- innerTpl chunk: I will need this so that outerTpl will not be reused here to avoid the id="menu1" being repeated here--> <li><a href="http://www.pivotx.net/">PivotX</a></li> <!-- innerRowTpl chunk: I don't need this so WF will use rowTpl to create inner level rows --> <li><a href="http://www.wordpress.org/">WordPress</a></li> <li><a href="http://www.textpattern.com/">Textpattern</a></li> <li><a href="http://typosphere.org/">Typo</a></li> </ul> </li>
<ul id="menu1" class="menu"> [+wf.wrapper+] </ul>
<li[+wf.classes+]> <a href="[+wf.link+]" title="[+wf.title+]" [+wf.attributes+]>[+wf.linktext+]</a> [+wf.wrapper+] </li>
<ul[+wf.classes+]> [+wf.wrapper+] </ul>
[[Wayfinder? &startId=`0` &level=`2` &outerTpl=`jqaccoutertpl` &innerTpl=`jqaccinnertpl` &rowTpl=`jqaccrowtpl`]]
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Tutorial Site | Home</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <base href="http://localhost:8888/TutorialONE/"></base> <link rel="stylesheet" href="assets/js/style.css" type="text/css" media="screen" /> <script src="assets/js/jquery-1.2.1.min.js" type="text/javascript"></script> <script src="assets/js/menu.js" type="text/javascript"></script> </head> <body> <div id="wrapper"> <ul><li class="active"><a href="http://localhost:8888/TutorialONE/" title="Home" >Home</a></li> <li><a href="/TutorialONE/index.php?id=2" title="Design" >Design</a></li> <li><a href="/TutorialONE/index.php?id=3" title="Contact" >Contact</a></li> <li><a href="/TutorialONE/index.php?id=4" title="Fruit" >Fruit</a><ul><li><a href="/TutorialONE/index.php?id=5" title="Apples" >Apples</a></li> <li><a href="/TutorialONE/index.php?id=6" title="Oranges" >Oranges</a></li> <li class="last"><a href="/TutorialONE/index.php?id=7" title="Lemons" >Lemons</a></li> </ul></li> <li class="last"><a href="/TutorialONE/index.php?id=8" title="Vegetables" >Vegetables</a><ul><li><a href="/TutorialONE/index.php?id=9" title="Squash" >Squash</a></li> <li class="last"><a href="/TutorialONE/index.php?id=11" title="Pumpkin" >Pumpkin</a></li> </ul></li> </ul> <h2>Welcome to the MODx Content Management System</h2> <p>This is content. Not much, but its a start...</p> </div><!-- end wrapper --> </body> </html>
body {
font-family: Helvetica, Arial, sans-serif;
font-size: 0.9em;
}
#wrapper{
background-color:yellow;
width:900px;
margin:0 auto;
}
p {
line-height: 1.5em;
}
ul.menu, ul.menu ul {
list-style-type:none;
margin: 0;
padding: 0;
width: 15em;
}
ul.menu a {
display: block;
text-decoration: none;
}
ul.menu li {
margin-top: 1px;
}
ul.menu li a {
background: #333;
color: #fff;
padding: 0.5em;
}
ul.menu li a:hover {
background: #000;
}
ul.menu li ul li a {
background: #ccc;
color: #000;
padding-left: 20px;
}
ul.menu li ul li a:hover {
background: #aaa;
border-left: 5px #000 solid;
padding-left: 15px;
}I then made your template example the default
I used your template example and made it the default template in the Tools Configuration page.
My code is not producing the <ul id="menu1" class="menu"> that is in the outerTpl. It simply does not show.
And the "active" and "last" classes are being added to the list somehow. Does Wayfinder do this automatically. I am looking for clues on this and have not found much.
What does you browser rendered code look like? I bet you are not getting those classes?
!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>My MODx Site | Testing Jquery Accordion Menu</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <base href="http://localhost/modx-0.9.6.3/"></base> <link rel="stylesheet" href="assets/js/style.css" type="text/css" media="screen" /> <script src="assets/js/jquery-1.2.1.min.js" type="text/javascript"></script> <script src="assets/js/menu.js" type="text/javascript"></script> </head> <body> <div id="wrapper"> <ul id="menu1" class="menu collapsible"> <li> <a href="http://localhost/modx-0.9.6.3/" title="Home" >Home</a> </li> <li> <a href="/modx-0.9.6.3/index.php?id=2" title="Blog" >Blog</a> </li> <li> <a href="/modx-0.9.6.3/index.php?id=15" title="MODx Features" >Features</a> <ul> <li> <a href="/modx-0.9.6.3/index.php?id=16" title="Ajax" >Ajax</a> </li> <li> <a href="/modx-0.9.6.3/index.php?id=22" title="Menus and Lists" >Menus and Lists</a> </li> <li> <a href="/modx-0.9.6.3/index.php?id=14" title="Content Management" >Manage Content</a> </li> <li class="last"> <a href="/modx-0.9.6.3/index.php?id=24" title="Extendable by design" >Extendability</a> </li> </ul> </li> <li> <a href="/modx-0.9.6.3/index.php?id=33" title="Getting Help" >Getting Help</a> </li> <li> <a href="/modx-0.9.6.3/index.php?id=39" title="Template Examples" >Templates</a> <ul> <li> <a href="index.php?id=39" title="MODxHost" >MODxHost</a> </li> <li> <a href="/modx-0.9.6.3/index.php?id=42" title="MODxCSS Wide" >MODxCSS Wide</a> </li> <li class="last"> <a href="/modx-0.9.6.3/index.php?id=43" title="MODxCSS" >MODxCSS</a> </li> </ul> </li> <li> <a href="/modx-0.9.6.3/index.php?id=32" title="Design" >Design</a> </li> <li> <a href="/modx-0.9.6.3/index.php?id=6" title="Contact Us" >Contact us</a> </li> <li class="last active"> <a href="/modx-0.9.6.3/index.php?id=47" title="Testing Jquery Accordion Menu" >Testing Jquery Accordion Menu</a> </li> </ul> <h2>Testing Jquery Accordion Menu</h2> <p>As you can see, the menu works!</p> </div><!-- end wrapper --> </body> </html>