Project

General

Profile

« Previous | Next » 

Revision 220

Added by stefan about 19 years ago

Some changes and fixes to menu code

View differences:

class.frontend.php
305 305
	   if (!isset($wb->menu_current_class)) {
306 306
	   	$wb->menu_current_class = ' class="menu_current"';
307 307
	   }
308
       if (!isset($wb->menu_parent)) {
309
     	$wb->menu_parent = 0;
308
	   if (!isset($wb->menu_parent)) {
309
	   	$wb->menu_parent = 0;
310 310
	   }
311 311
	   $wb->show_menu();
312
	   if ($start_level>0) {
313
	       $key_array=array_keys($wb->page_trail);
314
	       $real_start=$key_array[$start_level-1];
315
	       if (isset($real_start))
316
	       {
317
	       	$wb->menu_parent=$real_start;
318
	        $wb->show_menu();
319
	       }
320
	       return;
321
	   }
322

  
323 312
	}
324 313
	
325 314
	function show_menu() {
326 315
	   global $database;
327
	   global $wb;
328
	   if ($wb->menu_recurse==0)
316
	   if ($this->menu_start_level>0) {
317
	       $key_array=array_keys($this->page_trail);
318
	       $real_start=$key_array[$this->menu_start_level-1];
319
	       if (isset($real_start)) {
320
	       	$this->menu_parent=$real_start;
321
		$this->menu_start_level=0;
322
	       } else {
323
	       	 return;
324
	       }
325
	   }
326
	   if ($this->menu_recurse==0)
329 327
	       return;
330 328
	   // Check if we should add menu number check to query
331
	   if($menu_parent == 0) {
332
	       $menu_number = "menu = '$wb->menu_number'";
329
	   if($this->menu_parent == 0) {
330
	       $menu_number = "menu = '$this->menu_number'";
333 331
	   } else {
334 332
	      $menu_number = '1';
335 333
	   }
336 334
	   // Query pages
337 335
	   $query_menu = $database->query("SELECT page_id,menu_title,page_title,link,target,level,visibility FROM ".
338
	TABLE_PREFIX."pages WHERE parent = '$wb->menu_parent' AND $menu_number AND $wb->extra_where_sql ORDER BY position ASC");
336
	TABLE_PREFIX."pages WHERE parent = '$this->menu_parent' AND $menu_number AND $this->extra_where_sql ORDER BY position ASC");
339 337
	   // Check if there are any pages to show
340 338
	   if($query_menu->numRows() > 0) {
341 339
	   	  // Print menu header
342
	   	  echo "\n".$wb->menu_header;
340
	   	  echo "\n".$this->menu_header;
343 341
	      // Loop through pages
344 342
	      while($page = $query_menu->fetchRow()) {
345 343
	      	 // Check if this page should be shown
......
347 345
	         $vars = array('[class]','[a]', '[/a]', '[menu_title]', '[page_title]');
348 346
	         // Work-out class
349 347
	         if($page['page_id'] == PAGE_ID) {
350
	            $class = $wb->menu_current_class;
348
	            $class = $this->menu_current_class;
351 349
	         } else {
352
	            $class = $wb->menu_default_class;
350
	            $class = $this->menu_default_class;
353 351
	         }
354 352
	         // Check if link is same as first page link, and if so change to WB URL
355
	         if($page['link'] == $wb->default_link AND !INTRO_PAGE) {
353
	         if($page['link'] == $this->default_link AND !INTRO_PAGE) {
356 354
	            $link = WB_URL;
357 355
	         } else {
358
	            $link = $wb->page_link($page['link']);
356
	            $link = $this->page_link($page['link']);
359 357
	         }
360 358
	         // Create values
361 359
	         $values = array($class,'<a href="'.$link.'" target="'.$page['target'].'" '.$class.'>', '</a>', ($page['menu_title']), ($page['page_title']));
362 360
	         // Replace vars with value and print
363
	         echo "\n".str_replace($vars, $values, $wb->menu_item_template);
361
	         echo "\n".str_replace($vars, $values, $this->menu_item_template);
364 362
	         // Generate sub-menu
365
	         if($wb->menu_collapse==false OR ($wb->menu_collapse==true AND isset($wb->page_trail[$page['page_id']]))) {
366
	            $wb->menu_recurse--;
367
	            $wb->menu_parent=$page['page_id'];
368
	            $wb->show_menu();
363
	         if($this->menu_collapse==false OR ($this->menu_collapse==true AND isset($this->page_trail[$page['page_id']]))) {
364
	            $this->menu_recurse--;
365
	            $this->menu_parent=$page['page_id'];
366
	            $this->show_menu();
369 367
	         }
370
	         echo "\n".$wb->menu_item_footer;
368
	         echo "\n".$this->menu_item_footer;
371 369
	      }
372 370
	      // Print menu footer
373
	      echo "\n".$wb->menu_footer;
371
	      echo "\n".$this->menu_footer;
374 372
	   }
375 373
	}
376 374

  

Also available in: Unified diff