View submenu conditionally

I put together a combined horizontal and vertical navigation, the vertical (sub) menu will be displayed only when actually sub-menu items are available (this is for example the case on the product pages, but not at home).



Forum: Untermenü nur bedingt anzeigen
Autor: Oliver Georgi 2007/08/26



You can not automate everything within a CMS!

Some menu solution can be implemented only by custom logic.

But it's important - if possible do NOT use inline PHP. In your case it goes as follows:

In the template, add to the area where the vertical menu is to appear

[Note: All the “numbers” are levels of structure IDs]

Create a new file navi_left_right.php in template/inc_script/frontend_render/.. and fill in the following code:

{VERTMENU}

navi_left_right.php

<?php
// ----------------------------------------------------------------
// obligate check for phpwcms constants
if (!defined('PHPWCMS_ROOT')) {
   die("You Cannot Access This Script Directly, Have a Nice Day."); }
// ----------------------------------------------------------------
 
// Simple "View submenu conditionally"
// Forum: http://forum.phpwcms.org/viewtopic.php?p=90950#p90950
// Autor: Oliver Georgi 2007/08/26
// ----------------------------------------------------------------
 
 
$_vertmenu = '';
 
if(isset($LEVEL_ID[1])) {
 
  $_vertmenu = trim(   buildCascadingMenu( 'F,' . $LEVEL_ID[1] . ',' )   );
  // this is exactly the same as {NAV_LIST_UL: F,start_level_id, }
  // but built with php function behind
  if( $_vertmenu ) {
 
    $_vertmenu = '<div class="menu">' . $_vertmenu . '</div>';
 
  } else {
    $_vertmenu = '';
  }
 
}
 
$content['all'] = str_replace( '{VERTMENU}', $_vertmenu, $content['all'] );
 
?>


Use {VERTMENU} on the site in the template where you want to appear the result….


english/navigation/little-helper/view-submenu-conditionally.txt · Last modified: 2018/06/03 18:09 (external edit)
www.planmatrix.de www.chimeric.de Creative Commons License Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0