template position visible as white space if module disabled

GK User
Fri Jun 13, 2014 5:02 pm
Hi,
I have a module in sidebar position, but I don`t want module to show on every page. If I disable module for certain pages, the template position on those pages doesn't`t collapse i.e. there is white space showing, which is occupied by disabled module. How can I change that?
Any ideas?
User avatar
Fresh Boarder

GK User
Fri Jun 13, 2014 7:23 pm
Hello,

Could you provide an URL to your website with this problem?
User avatar
Administrator

GK User
Fri Jun 13, 2014 11:56 pm
hi,
the URL is:
http://pazzazz.nl/
User avatar
Fresh Boarder

GK User
Sun Jun 15, 2014 8:02 pm
Sorry but your page is offline.
User avatar
Administrator

GK User
Sun Jun 15, 2014 11:49 pm
Sorry, it was a couple of minutes offline. It is now online again
User avatar
Fresh Boarder

GK User
Mon Jun 16, 2014 7:49 pm
Are you sure that there is no modules published on this module position? For me it looks like empty module published on the sidebar. There is no additional module container because as I see you are using module style "none" on the sidebar.
User avatar
Administrator

GK User
Tue Jun 17, 2014 11:36 pm
Sorry, maybe I was not clear enough. There is a module in "sidebar position" that is assigned to Products category's (and you can see it if you click in the menu on one of product category`s), but I do not want it (the module) on single product page (so I turned it off for single product page). The module is not showing on single product page (as I intended) but the white space remains on the "sidebar position" . I hope I was more clear this time.
Thanks
User avatar
Fresh Boarder

GK User
Wed Jun 18, 2014 9:11 am
It means that the module doesn't display the output but still is loaded on the single pages - in my opinion the only solution in this case is display other module with content to fill the white space.
User avatar
Administrator

GK User
Wed Jun 18, 2014 11:42 pm
Thanks, I know what it means and I know that I can display other module with content to fill the white space, but that is not the solution for me. I don`t want other stuff instead of the white space; I just wont the template position to collapse if empty. As far as I know the actual display of the modules, including the module position, is entirely handled by the template, not by Joomla itself, that`s the reason I posted my question here.
If you take a look at the attached image, you will see that there is an empty DIV (id="gkSidebar" class="gkOnlyOne") 307px x 0px, occupying that position.
How can I change that?
Is the countModules method (or something similar) used in the template to determine if a module is in fact set for the position?
User avatar
Fresh Boarder

GK User
Thu Jun 19, 2014 9:24 am
Our templates are using the native Joomla! functions for detecting if the module is enabled and should be displayed. The mentioned module position isn't empty - it contains a module, but it is a module which doesn't generate an output.
User avatar
Administrator

GK User
Fri Jun 20, 2014 3:14 am
I guess the reason for the problem is that the single product pages doesn't have menu item assigned to it (the pages are pulled from the component), so I can not manually disable the module for those pages .
Anyway, I think that I found the article dealing with this problem, but I don`t know how to implement the code and where to put it. Maybe you can help me with that.
The URL of the article is: http://www.spiralscripts.co.uk/Joomla-T ... splay.html
and it deals with this problem after the line:
This can lead to the module position still being rendered...
Thanks
User avatar
Fresh Boarder

GK User
Sat Jun 21, 2014 10:47 pm
In my opinion it is not a good solution, because it will cause double rendering of the sidebar modules, but if it is an only solution please use the following code:

Code: Select all
//check bottom module position
$showSidebar = false;
$sidebarModules = JModuleHelper::getModules( 'sidebar' );
if(count($sidebarModules)>0)
{
   foreach($sidebarModules as $sidebarMod)
   {
      if(JModuleHelper::renderModule($sidebarMod) != "")
      {
         $showSidebar = true;   
      }
   }
}


You have to place it in the all files which uses in the conditions the following code:

Code: Select all
$this->API->modules('sidebar')


and of course you have to replace the condition to:

Code: Select all
$showSidebar
User avatar
Administrator


cron