WebsiteBaker Support (2.8.x) > Templates, Menus & Design

Resposive or mobile friendly template

<< < (4/10) > >>

applepie:

--- Quote from: instantflorian on May 12, 2015, 07:19:38 PM ---Looks for me like an error with the ' signs in the SM2 call.

--- End quote ---
It still doesn't make sense to me. Do you mind have a look and let me know where I have gone wrong please? My code at present below.

   /*Men?s*/
   ob_start();
   
   show_menu2(1, SM2_ROOT, SM2_ALL, SM2_ALL, '<li class="[class]"><a href="[url]" class="[class]"><span>[menu_title]</span></a>', "</li>", '<ul>', '<li class="ulend"></li></ul>', true, '<ul id="mobile" class="nav">');
   $topmenu = ob_get_contents();
   ob_end_clean();
      
   $childpages = '';   
   ob_start();
   show_menu2(0, 19, SM2_ALL, SM2_ALL, '', '<li class="[class]">[a][menu_title]</a></li>', '', '', '', '');   
   $childpages = ob_get_contents();   
   ob_end_clean();    
   
?>

instantflorian:
Your sm2 calls are wrong. You added an page id at the 2nd position, so the other parameters are not at the right place any more. The order and position of the parameters are very important.

When modifying and testing, it might be easier to use the "long call" with the variable names, so you see at once where to change what:


--- Code: ---<?php
show_menu2(
    $aMenu          = 0,
    $aStart         = SM2_ROOT,
    $aMaxLevel      = SM2_CURR+1,
    $aOptions       = SM2_TRIM,
    $aItemOpen      = '[li][a][menu_title]</a>',
    $aItemClose     = '</li>',
    $aMenuOpen      = '[ul]',
    $aMenuClose     = '</ul>',
    $aTopItemOpen   = false,
    $aTopMenuOpen   = false
    )

--- End code ---

So in your case sth. like this


--- Code: ---<?php
show_menu2(
    $aMenu          = 0,
    $aStart         = 19,
    $aMaxLevel      = SM2_ALL,
    $aOptions       = SM2_ALL,
    $aItemOpen      = '<li class="[class]">[a][menu_title]</a></li>',
    $aItemClose     = '',
    $aMenuOpen      = '',
    $aMenuClose     = '',
    $aTopItemOpen   = false,
    $aTopMenuOpen   = false
    )

--- End code ---

Furthermore, it usually doesn't make sense to hardcode the page id for the start of a submenu into the template. In your code (if it would be working), you would see the childpages of page 19 on every other page too. I'm not sure if it is that what you wanted to reach.

The menu configuration is probably the most complicated point of building a WB template.
You will find more information and typical menu calls here in the forum (german)

Edit:
See also here

applepie:

--- Quote from: instantflorian on May 15, 2015, 07:55:47 AM ---
Furthermore, it usually doesn't make sense to hardcode the page id for the start of a submenu into the template. In your code (if it would be working), you would see the childpages of page 19 on every other page too. I'm not sure if it is that what you wanted to reach.

The menu configuration is probably the most complicated point of building a WB template.
You will find more information and typical menu calls here in the forum (german)

--- End quote ---
Hi, the codes works fine on my old template. Yes, that's correct. I want all the child pages showing on all my pages. I am trying to implement the same thing on the template  daflekk or responsive-blue but it doesn't work on them.
Sorry, I can't read German :(

applepie:
I have attached an image to explain what I am trying to achieve. The submenu or childpages showing on all pages. Can anyone help please? Tried the suggestions and still not working. I am not an expert in this and can't find my head round it. Thanks.

DarkViper:
try this .. maybe it helps..

--- Code: ---<?php
// create main menue
    $sMainNavi = show_menu2(
        1,
        SM2_ROOT,
        SM2_START + 1,
        SM2_ALL|SM2_PRETTY|SM2_CURRTREE|SM2_BUFFER, 
        '<li class="[class]"><a href="[url]" class="[class]" title="">[if(class==menu-current && level>1){&#38;#10144;&nbsp;}][menu_title]</a>',
        '</li>',
        '<ul class="[class]">',
        '</ul>',
        '<li class="[class]"><a href="[url]" class="[class]" title="">[menu_title]</a>',
        '<ul class="[class]">'
    );
// create sub menue title
    $sSubNaviTitle = show_menu2(
        1,
        SM2_ROOT,
        SM2_START,
        SM2_TRIM|SM2_BUFFER,
        '[if(class = menu-current || class = menu-parent){[menu_title]}]',
        '',
        '',
        '',
        '',
        ''
    );
// remove possible comments and whitespaces from result 
    $sSubNaviTitle = trim(preg_replace('/<\!--.*?-->/siu', '', $subMenuTitle));
// create main menue sub
    $sSubNavi = show_menu2(
        1, SM2_ROOT+1, SM2_CURR+1, SM2_SIBLING|SM2_CURRTREE|SM2_PRETTY|SM2_BUFFER,
        '[li][ac][if(class==menu-current){&#38;#10144;&nbsp;}][menu_title]</a>',
        '</li>',
        '<ul>',
        '</ul>',
        '',
        ''
    );
// remove possible comments and whitespaces from result 
    $sSubNavi = trim(preg_replace('/<\!--.*?-->/siu', '', $sSubNavi));
// show all
echo '<div>'.$mainNavi.'</div>';
// [...] output something others
if ($sSubNavi) { // show submenu only if sub items exists
    echo '<div>'.$sSubNaviTitle.'</div>';
    echo '<div>'.$sSubNavi.'</div>';
}


--- End code ---

Manuela

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version