<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta content="text/html;charset=ISO-8859-1" http-equiv="Content-Type">
<title></title>
</head>
<body bgcolor="#ffffff" text="#000000">
Thanks. I actually tried that technique first (it shows at the bottom
of this email), before trying the options below, but what I found was
that the primary_links menu wasn't populated with it's children which
is why i started digging around these deeper parts of the system - what
i was initially looking for was to find a function that I could call
that would give me the full array (like what shows if you use the
default menu module). <br>
<br>
print_r output gives:<br>
<pre id="line49">Array
(
[menu-1-1-2] => Array
(
[title] => Photo Gallery
[href] => node/2
[attributes] => Array
(
)
)
[menu-1-2-2] => Array
(
[title] => Floor Plans
[href] => node/5
[attributes] => Array
(
)
)
)
1<span class="comment"></span></pre>
Even though Photo Gallery has a child which is listed if you load the
default menu module that comes with drupal:<br>
<pre id="line49"><<span class="start-tag">ul</span><span
class="attribute-name"> class</span>=<span class="attribute-value">"menu"</span>>
<<span class="start-tag">li</span><span class="attribute-name"> class</span>=<span
class="attribute-value">"expanded"</span>><<span
class="start-tag">a</span><span class="attribute-name"> href</span>=<span
class="attribute-value">"/?q=photoGallery"</span>>Photo Gallery</<span
class="end-tag">a</span>>
<<span class="start-tag">ul</span><span class="attribute-name"> class</span>=<span
class="attribute-value">"menu"</span>>
<<span class="start-tag">li</span><span class="attribute-name"> class</span>=<span
class="attribute-value">"leaf"</span>><<span class="start-tag">a</span><span
class="attribute-name"> href</span>=<span class="attribute-value">"/?q=photoGallery/residential"</span>>Residential Photos</<span
class="end-tag">a</span>></<span class="end-tag">li</span>>
</<span class="end-tag">ul</span>>
</<span class="end-tag">li</span>>
<<span class="start-tag">li</span><span class="attribute-name"> class</span>=<span
class="attribute-value">"leaf"</span>><<span class="start-tag">a</span><span
class="attribute-name"> href</span>=<span class="attribute-value">"/?q=floorplans"</span>>Floor Plans</<span
class="end-tag">a</span>></<span class="end-tag">li</span>>
</<span class="end-tag">ul</span>></pre>
<br>
So I guess the question is - how do I get a primary link's children (eg
Residential Photos) to appear in an array I can traverse?<br>
<br>
<br>
Eric Mckenna wrote:
<blockquote cite="mid:46C5B5F7.8010302@gmail.com" type="cite">
<pre wrap="">Forgot to to add that you will have to get intimate with the
$primary_links array, but its not difficult.
Throw in a print_r($links) and you have all you need.
Eric Mckenna wrote:
</pre>
<blockquote type="cite">
<pre wrap="">You can use theme_menu_tree and theme_menu_item, but you will theme
every menu that passes through the menu system that way.
What I like to do is do my own theme for the menu items
on your page.tpl.php
<?php print theme('my_menu_themeing', $primary_links); ?>
inside your template.tpl.php
function THEME_NAME_my_menu_themeing($links) {
$output;
.. custom html with my menu ...
return $output;
}
see it that works for you.
Eric.
sander-martijn wrote:
</pre>
<blockquote type="cite">
<pre wrap="">Making some progress here. I've realized that to some extent what I
want to do is override theme_menu_tree and theme_menu_item. That
gives me some of the control I need BUT the default menu system still
has extra junk I don't want (such as a Primary links header) AND I
need two types of menu trees that display different things - one
horizontal in the top (primary links) and one vertical down the left
(current section and its children).
so far i think menus are a pain in the ass in drupal. a tradeoff for
the power but I think the multiple meanings that the word "menu" has
in drupal just adds to the confusion of it all. What I need is
really not that complicated, but it's becoming incredibly complicated
fast.
sander-martijn wrote:
</pre>
<blockquote type="cite">
<pre wrap="">I want to customize my menus, but since I want it to work with the
html/css/javascript code I've already written and tested I want to
get the system to output the menu in html as I want it. Actually
what I need is quite simple. I don't really want to try to
customize someone else's module and I'd rather not build one. After
some digging around I figured out that I could override the
theme_menu_links method in my template.php file. Now that's exactly
what I need... I got really excited but I must have some things
missing/misunderstood.
what I have in the menu system under primary links:
primary links
- menu item 1
- menu 1 subitem 1
- menu 1 subitem 2
- menu item 2
- menu 2 subitem 1
etc - fairly standard
What I need to output is the following:
<ul id="nav1" class="nav">
<li><a href="#">menu item 1</a>
<ul>
<li><a href="#">menu 1 subitem 1</a></li>
<li><a href="#">menu 1 subitem 2</a></li>
</ul>
</li>
</ul>
<ul id="nav2" class="nav">
<li>menu item 2
<ul>
<li><a href="#">menu 2 subitem 1</a></li>
</ul>
</li>
</ul>
etc. - also pretty straight forward.
SO - I put in page.tpl.php the following:
<?php print theme('menu_links', $primary_links); ?>
and put in template.php the following:
function tpg_menu_links($links){
if (!count($links)) {
return '';
}
$level_tmp = explode('-', key($links));
$level = $level_tmp[0];
$output = "<ul id=\"nav\" class=\"nav\">\n";
foreach ($links as $index => $link) {
$output .= "<li>". l($link['title'], $link['href'],
$link['attributes'], $link['query'], $link['fragment']) ."</li>\n";
}
$output .= '</ul>';
return $output;
}
?>
Which is basically a modified version of theme_menu_links in menu.inc
It works as a start, but there are a couple of issues. 1. even
though my class attribute in $output is hard coded, it's still being
replaced by class="active" when you're on the page. Not a disaster,
i can always modify my css to do the same thing for class="active"
as class="nav".
2. this is the bigger issue. It's not outputting the subitems. I'd
be happy to add in the proper call in the foreach loop to either
call another function that i also override or to load them directly
in here if anyone can point me in the direction of what i need to
call in order to load them.
</pre>
</blockquote>
<pre wrap="">--
------------------------------------------------------------------------
sander-martijn <a class="moz-txt-link-rfc2396E" href="mailto:sander@sander-martijn.com"><mailto:sander@sander-martijn.com></a>
interface developer | architect
<a class="moz-txt-link-abbreviated" href="mailto:sander@sander-martijn.com">sander@sander-martijn.com</a> <a class="moz-txt-link-rfc2396E" href="mailto:sander@sander-martijn.com"><mailto:sander@sander-martijn.com></a>
<a class="moz-txt-link-abbreviated" href="http://www.sander-martijn.com">www.sander-martijn.com</a> <a class="moz-txt-link-rfc2396E" href="http://www.sander-martijn.com"><http://www.sander-martijn.com></a>
------------------------------------------------------------------------
</pre>
</blockquote>
<pre wrap="">
</pre>
</blockquote>
<pre wrap=""><!---->
</pre>
</blockquote>
<br>
<div class="moz-signature">-- <br>
<hr align="center" noshade="noshade" size="1" width="100%">
<p
style="text-align: center; font-family: verdana,arial,helvetica,sans-serif; color: rgb(51, 51, 51); font-size: 10px; text-transform: lowercase; font-style: normal; font-weight: normal;"><a
href="mailto:sander@sander-martijn.com"
style="text-decoration: none; color: rgb(0, 0, 255); font-family: verdana,arial,helvetica,sans-serif;">sander-martijn</a><br>
interface developer | architect<br>
<a href="mailto:sander@sander-martijn.com"
style="text-decoration: none; color: rgb(0, 0, 255); font-family: verdana,arial,helvetica,sans-serif;">sander@sander-martijn.com</a><br>
<a href="http://www.sander-martijn.com"
style="text-decoration: none; color: rgb(0, 0, 255); font-family: verdana,arial,helvetica,sans-serif;">www.sander-martijn.com</a>
</p>
<hr align="center" noshade="noshade" size="1" width="100%"></div>
</body>
</html>