Splitting up the menu file

From phpCMS

Jump to: navigation, search

If the menu file is getting too large, you'll run into problem if there's no menu number defined within the content file. phpCMS will be the more slower the bigger the menu file is - and may be even reaching a script timeout.

Contents

[edit] Solution

You can patch the menu parser.
Patch by Samson (30.11.2004)

Thereby all sub menus are exported to files named sub.mnu located in the respective sub directories.

Remark: This patch is suitable only for those who can forbear offering a sitemap.

[edit] Patching class.parser_menu_phpcms.php

Look for the function menu (about line 50) and add the object $CHECK_PAGE to the global variables:

global $DEFAULTS,$CHECK_PAGE;

After $this->content = new File($DEFAULTS->MENU); add the following code to line 56:

$temppath = $CHECK_PAGE->path;
$temptrenner=1;
while($temptrenner>0) {
  if(file_exists($DEFAULTS->DOCUMENT_ROOT.$temppath."/sub.mnu")) {
    $this->content1 = new File($DEFAULTS->DOCUMENT_ROOT.$temppath."/sub.mnu");
    $this->content->lines = array_merge($this->content->lines,$this->content1->lines);
  }
  $temptrenner = strrpos($temppath,"/");
  $temppath = substr($temppath,0,$temptrenner); 
}

[edit] Operating Mode

The parser is instructed to look for a file sub.mnu within all higher-level directories, based on the current directory. The content of each sub.mnu file found will be added to the menu object.

[edit] Example

The main menu files has the following content:

MENU: MAIN
CLASS;TEXT;LINK;ALT;ZIEL
00.00;Aktuelles;/index.html;Homepage;_top
00.08;Archiv;/events/index.html;Frühere Meisterschaften und Open;_top
00.03;Geschichte;/historie/index.html;Berliner Schachgeschichte;_top
00.01;DWZ/BWZ;/archiv/rating/index.html;DWZ und BWZ;_top
00.04;Forum;/forum/index.html;Schachforum;_top
00.06;Gästebuch;/gaestebuch/index.html;Gästebuch;_top
00.10;Links;/links/index.html;Links;_top
00.11;Download;/download/index.html;Download;_top
00.09;Jugendschach;/jugend/;Jugendschach;_top

The archive menu having the number 00.08 has been exported to the file sub.mnu in the directory /events and has the following content:

MENU: SUB1
CLASS;TEXT;LINK;ALT;ZIEL
00.08.00;Open;/events/open/index.html;Open in und um Berlin;_top
00.08.01;BSV;/events/bsv/index.html;Meisterschaften des BSV;_top
00.08.02;Berlin;/events/berlin/index.html;Berichte aus Berlin;_top
00.08.03;Deutschland;/events/deutschland/index.html;Turniere in Deutschland;_top
00.08.07;Ausland;/events/ausland/index.html;Ausländische Berichte;_top
00.08.06;Spielerwahl;/events/berlin/spielerwahl/index.html;Wahl;_top
00.08.05;Statistik;/events/statistik/index.html;Diverse Statistiken;_top

The parser reads this sub menu only when a file from the /events directory has been requested.

Main Page: Tutorials MainPage | Top Page: MiniHowTos MainPage

Diese Seite in anderen Sprachen: Deutsch

Personal tools