Posted by karengreen on October 8, 2009 at 10:53am
| Project: | footermap: a footer site map |
| Version: | 6.x-1.5 |
| Component: | Code |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | closed (fixed) |
Issue Summary
Good morning,
I came across your module as a more practical way of displaying a sitemap at the bottom of each page without creating a view.
However, as my content grows, i dont want my footer to become enormous.
Can you show me how to ammend the module so that it will only display the first 5 children under each menu category.
Many thanks!
Comments
#1
#2
This is actually a bit difficult to implement as a feature in the module itself for all cases and have it work for everyone the way they want.
For your particular situation, it may be best to patch (hack) the module slightly for your own needs. If you know how to apply a patch, this bit of code may help your situation.
I don't think this is going to be a feature that I'll implement permanently.
edit: it should apply to the development version, but you'll need to wait 12-14 hours before that updates before you apply it.
#3
Hi,
Ive applied the patch but it doesnt seem to make any difference.
Any other ideas?
#4
Whoops. I forgot to explain the patch in my previous post.
There are two numbers that you'll need to change around. I just put them in arbitrarily.
On this line:
if ($level > 3 && $mycount < 5)Put the menu depth after which you want this to start working. So if you wanted it at the second level, replace the 3 with a 1. I would recommend setting this number to the Recursion Depth - 1.
The second number is how many items you want it to go to. Note: that if a menu has child items neither will show up if there are more or equal parent items than this number.
Example:
Let's say you only wanted 3 child items under the main item.
Set the first number to 1 and set the second number to 4.
This should have everything but the Impressionist item and its child items and the Random item.
#5
Ok i changed the two values but still not getting the right output.
Ive included a couple screenshots so you can see whats going on.
When setting level to 1 it only shows the parent item.
When setting level to 2 it displays all the children but doesnt stop when mycount reaches its value (so it keeps going after the 5th increment) (also - it doesnt matter what value i put into $mycount - it seems to ignore it)
Is there something im forgetting to do?
to clarify - my function footermap_get_menu() looks like this:
function footermap_get_menu($mlid,$level,$limit,&$mapref,$arrcnt,$avail_menus)
{
global $db_type;
if( ($limit != 0 ) && ($level > $limit) )
return;
if (variable_get('sys_menus',0) == 0)
$add = " AND ml.module <> 'system' ";
else
$add = ' ';
if( module_exists('path') )
$r = db_query("SELECT ml.*, (SELECT ul.dst FROM {url_alias} ul WHERE src = ml.link_path) AS alias FROM {menu_links} ml WHERE ml.plid = %d AND ml.hidden <> -1".$add."ORDER BY ml.plid,ml.weight",$mlid)
or die(db_error());
else
$r = db_query("SELECT ml.* FROM {menu_links} ml WHERE ml.plid = %d AND ml.hidden <> -1".$add."ORDER BY ml.plid,ml.weight", $mlid)
or die(db_error());
$mycount = 0;
while( $h = db_fetch_object($r) )
{
if ($level > 1 && $mycount < 6) //show only 5 items
return;
$mycount++;
if (preg_match("/node\/(\d+)/",$h->link_path,$matches) == 1)
$node = node_load($matches[1]);
$g = 0;
...and so on.
#6
Doh - after all that i figured it out!
if ($level > 1 && $mycount > 4)
mycount should be higher than, not lower than :)
Thanks for your help!
#7
Sorry for the confusion.
#8
Automatically closed -- issue fixed for 2 weeks with no activity.