Resposive or mobile friendly template

instantflorian

The following finally should do the trick. It shows in the left column permanently all child items of page 19.



/*Menüs*/
ob_start();
show_menu2(
    $aMenu          = 0,
    $aStart         = SM2_ROOT,
    $aMaxLevel      = SM2_START,
    $aOptions       = SM2_ALL,
    $aItemOpen      = '<li class="[class]"><a href="[url]" class="[class]"><span>[menu_title]</span></a>',
    $aItemClose     = '</li>',
    $aMenuOpen      = '<ul>',
    $aMenuClose     = '<li class="ulend"></li></ul>',
    $aTopItemOpen   = true,
    $aTopMenuOpen   = '<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();



In the 2nd menu call it's important that there's no " ,'' " after the 2nd SM2_ALL! Otherwise you well get the wrong "[a] [menu]" output. I've tested it.

You should maybe change the line


<div id="leftboxdesktop" class="leftbox desktops_only"><div class="inner">


to

<div id="leftboxdesktop" class="leftbox"><div class="inner">


otherwise the left column is not displayed on mobile devices.

DarkViper

#20
try this .. maybe it helps..
<?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(
        
1SM2_ROOT+1SM2_CURR+1SM2_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>';
}



Manuela
[url=http://www.youtube.com/watch?v=tmzDAz6ZvFQ]Der blaue Planet[/url] - er ist nicht unser Eigentum - wir haben ihn nur von unseren Nachkommen geliehen[br]
[i]"You have to take the men as they are... but you can not leave them like that !" :-P [/i]
[i]Das tägliche Stoßgebet: [b]Oh Herr, wirf Hirn vom Himmel ![/b][/i]

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.

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)
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 :(

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:


<?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
    
)


So in your case sth. like this


<?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
    
)


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 12, 2015, 07:19:38 PM
Looks for me like an error with the ' signs in the SM2 call.
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

Looks for me like an error with the ' signs in the SM2 call.

applepie

Quote from: instantflorian on May 12, 2015, 03:57:10 PM
Have a look at the index.php of the template, at line 91ff. you'll find two show_menu calls.
Hi again, I spent last few hours trying to work this out. I have used show_menu2(0, SM2_ROOT+1, SM2_START, SM2_ALL for the childpages and my result show:
[a][menu_title]
[a][menu_title]
[a][menu_title]
[a][menu_title]
[a][menu_title]
[a][menu_title]

Any idea where went wrong?  :?

instantflorian

#13
Have a look at the index.php of the template, at line 91ff. you'll find two show_menu calls.
Refer to Tutorial link removed 404 to find out how to change the sm2 calls to show only the root elements in the main navigation and always the child elements in the left column.

applepie

Quote from: instantflorian on May 12, 2015, 08:11:35 AM
Generally spoken, a left column for showing the sub navigation is not particularly needed as all childpages are listed in the main navigation bar.
Thanks for taking the time to fix this. Greatly appreciated. I think what I needed is the sub-menus showing on all the pages on the left. Your template is not showing at the moment. I don't want showing from the main menu.  How can I get it showing on all the pages? Cheers

instantflorian

See attachment.
I just changed the float of the former right column to float:left and removed the checks if the 2nd block has content, so the column is always shown.
On small screens, the left column is shown beyond the main content.
The sub menu needs some more styling of course.

I guess the same way responsive blue could be modified.

Generally spoken, a left column for showing the sub navigation is not particularly needed as all childpages are listed in the main navigation bar.


applepie

Quote from: instantflorian on May 11, 2015, 04:03:20 PM
Hi,

the template repository shows its pages in the last template you personally tested, so nobody else knows which template you mean. Please tell us the name of the template.


Oops, it is the responive blue and daflekk. Particularly the daflekk.
Thanks

instantflorian

Hi,

the template repository shows its pages in the last template you personally tested, so nobody else knows which template you mean. Please tell us the name of the template.

applepie

Quote from: nibz on April 30, 2015, 10:30:19 AM
http://websitebaker.at/wb-templates/search/top30-downloads.html
Is this particular template responsive? I like the left column. I would like to add submenu to it. The submenu needs to appear on all pages. How can I do that? How will it shows on mobile screen if I do?
This venture proved to be more challenge than I realised.



applepie

Thank you guys. That was very helpful. I will at them. Are the templates restricted to wb version. My wb version is rather old.


nibz

On a desktop you should see a sidebar on the right hand side, there you can search for templates.
Or here are the top downloads for this month: http://websitebaker.at/wb-templates/search/top30-downloads.html (NOT ALL ARE RESPONSIVE!)


applepie

Quote from: nibz on April 29, 2015, 04:38:50 PM
Here are some really nice free responsive templates: http://websitebaker.at/wb-templates/
Hi, are you referring to this template as seen or I can get some from this site?
Thanks

nibz


applepie

I am looking for a mobile friendly template. Is there one available? My site design is nice looking when I first designed it but now it so ugly on mobile. It is all over the place and look terrible. Suggestion and help please. Thanks