Forgot your password?   No account Yet? Register
swMenuPro Logo
Advanced Menu System for Joomla
Board index swMenuPro Forum swMenuPro9.0+ hide if empty

hide if empty

Please post all questions regarding swMenuPro 9+ to this forum.

Post Tue Mar 18, 2014 3:55 pm
SnigX Newbie
Newbie

Posts: 10

Hi,

I use SwMenuPro 9.8 to create a split top/left menu, but when there is no submenu items its still showing the left menu, which it shouldn't :(

Any idéas?

I tried the forum at joomla.org but so far no luck so I thought maybe you guys know something that can help :)

My post at joomla.org
http://forum.joomla.org/viewtopic.php?f=615&t=839213&p=3153632#p3153632

Post Tue Mar 18, 2014 5:17 pm
SnigX Newbie
Newbie

Posts: 10

The problem as I see it now is that the SwMenuPro still put some code in the left hand menu even if there are no menu items.

In the joomla forum they figured out how to remove <div class="moduletable"> by changing the style xhtml to none but the <script> and comments are still there.

You can see the test site here: http://mchandy.dk/

Hope you can help me out :)

Post Wed Mar 19, 2014 5:42 am
Sean White User avatar
Administrator
Administrator

Posts: 5489

There are quite a few ways to solve this.

I take it you are using the split menu option, so you have set a parent level for the side menu then set it to display on all pages. swMenuPro is still writing some comment tags and an empty script tag because they are outside of the loop that swMenuPro uses to determine if there are any menu items to display. It should not make any difference however,a comment and an empty script tag should not render as anything on your site.

The issue you are having is that joomla still thinks the swMenupro module is published on these pages, because it is. It's not really possible for swMenuPro to alter the css that joomla is placing around your modules, even if the module is empty.

Easiest solution is just to change the "show on all pages" in the module settings. You can use the normal joomla module manager to set the module to only display on the specific pages relating to menu items that are a top parent or submenu. Disadvantage of this is that you have to set it to show each time you add a new page.

If your after a more automatic solution then you would need to add some code to your templates index.php file. In your joomla forum topic you had this solution:

<?php
$submenu = trim($this->getBuffer('modules', 'left', array('style'=>'xhtml')));
if(!empty($submenu)) { ?>
<div id="content_left">
<jdoc:include type="modules" name="left" style="xhtml" />
</div>
<?php } ?>


That will work with a slight change. The $submenu variable isn't actually empty, but = 204 when there is no menu items. so change the line in red to that code:


<?php
$submenu = trim($this->getBuffer('modules', 'left', array('style'=>'xhtml')));
if(strlen($submenu)>250) { ?>
<div id="content_left">
<jdoc:include type="modules" name="left" style="xhtml" />
</div>
<?php } ?>


I've tried the solution just above and it works well providing it is the only module published in the left position.

Post Wed Mar 19, 2014 8:41 pm
SnigX Newbie
Newbie

Posts: 10

Ahh nice! it worked :D

Thx a bunch! Much better than to select specific pages where the submenu appear :)


Return to swMenuPro9.0+

cron