Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Function menu_data not returning ALL menu items
#1
I created a component to display the menu_data() array. I have three pages defined, all are on the menu and none are private. Also, I'm using PRETTYURLS. When I call it without params, it returns one array element for the index file. If I call it with a slug, it returns that slug's page info (as advertised), but its not returning ALL menu items.

Code:
if ($PRETTYURLS == '1') {
                        if ($parent != '') {$parent = $parent."/"; }
                        if ($slug == 'index' ) { $slug = ''; }
                        $url = $SITEURL . @$parent . $slug;
                    } else {
                        $url = $SITEURL .'index.php?id='.$slug;
                    }

                    $specific = array("slug"=>$slug,"url"=>$url,"parent_slug"=>$parent,"title"=>$title,"menu_priority"=>$pri,"menu_text"=>$text);

                    if ($id == $slug) {
                        return $specific; exit;
                    } else {
                        $menu_extract[] = $specific;
                    }

I suspect its in this area, perhaps something to do with setting the slug to '' when the slug = 'index'... but not sure. Could someone take a look? Thanks.


Update and Fix: I believe a suitable fix is;

Code:
// if ($slug == 'index' ) { $slug = ''; }
$url = $SITEURL . @$parent . (($slug == 'index') ? '' : $slug);

This works for me.
Reply


Messages In This Thread
Function menu_data not returning ALL menu items - by bnowell - 2009-08-25, 04:19:56



Users browsing this thread: 1 Guest(s)