The following warnings occurred:
Warning [2] Undefined array key "threadviews_countguests" - Line: 745 - File: showthread.php PHP 8.1.31 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/showthread.php 745 errorHandler->error_callback
Warning [2] Undefined array key "allowautourl" - Line: 584 - File: inc/class_parser.php PHP 8.1.31 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/inc/class_parser.php 584 errorHandler->error_callback
/inc/class_parser.php 228 postParser->parse_mycode
/inc/functions_post.php 830 postParser->parse_message
/showthread.php 916 build_postbit
Warning [2] Undefined property: MyLanguage::$thread_modes - Line: 46 - File: showthread.php(1650) : eval()'d code PHP 8.1.31 (Linux)
File Line Function
/inc/class_error.php 153 errorHandler->error
/showthread.php(1650) : eval()'d code 46 errorHandler->error_callback
/showthread.php 1650 eval




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: 3 Guest(s)