background images showing even when no module

Replied by Boradan on topic background images showing even when no module

Posted 8 years 8 months ago #29457
to a certain extent, that is already being done correctly.

Here is the part of the code from my current template I am working on. This is ONLY the code for the main content section with the modulestop, maintop, centertop, left, right, mainbottom and centerbottom. (its the base model 14 from the template creation except I have renamed some of them.
Code:
<div id="wrapper"> <div class="inner ui-sortable container"> <?php if ($nbmodules13) : ?> <section id="modulestop"> <div class="inner clearfix <?php echo 'n'.$nbmodules13 ?>"> <?php if ($this->countModules('header-a')) : ?> <div id="modulestopmod1" class="flexiblemodule "> <div class="inner clearfix"> <jdoc:include type="modules" name="header-a" style="xhtml" /> </div> </div> <?php endif; ?> <?php if ($this->countModules('header-b')) : ?> <div id="modulestopmod2" class="flexiblemodule "> <div class="inner clearfix"> <jdoc:include type="modules" name="header-b" style="xhtml" /> </div> </div> <?php endif; ?> <?php if ($this->countModules('header-c')) : ?> <div id="modulestopmod3" class="flexiblemodule "> <div class="inner clearfix"> <jdoc:include type="modules" name="header-c" style="xhtml" /> </div> </div> <?php endif; ?> <?php if ($this->countModules('header-d')) : ?> <div id="modulestopmod4" class="flexiblemodule "> <div class="inner clearfix"> <jdoc:include type="modules" name="header-d" style="xhtml" /> </div> </div> <?php endif; ?> <?php if ($this->countModules('header-e')) : ?> <div id="modulestopmod5" class="flexiblemodule "> <div class="inner clearfix"> <jdoc:include type="modules" name="header-e" style="xhtml" /> </div> </div> <?php endif; ?> <div class="clr"></div> </div> </section> <?php endif; ?> <div id="maincontent" class="maincontent <?php echo $mainclass ?>"> <div class="inner clearfix"> <?php if ($this->countModules('sidebar-a')) : ?> <aside id="left" class="column column1"> <?php if ($this->countModules('sidebar-a')) : ?> <div class="inner clearfix"> <jdoc:include type="modules" name="sidebar-a" style="xhtml" /> </div> <?php endif; ?> </aside> <?php endif; ?> <div id="main" class="column main row-fluid"> <div class="inner clearfix"> <?php if ($this->countModules('maintop')) : ?> <div id="maintopmodule"> <div class="inner clearfix"> <jdoc:include type="modules" name="maintop" style="xhtml" /> </div> </div> <?php endif; ?> <div id="maincenter" class="maincenter "> <div class="inner clearfix"> <main id="center" class="column center "> <div class="inner"> <?php if ($this->countModules('centertop')) : ?> <div id="centertopmodule"> <div class="inner clearfix"> <jdoc:include type="modules" name="centertop" style="xhtml" /> </div> </div> <?php endif; ?> <div id="content" class=""> <div class="inner clearfix"> <jdoc:include type="message" /> <jdoc:include type="component" /> </div> </div> <?php if ($this->countModules('centerbottom')) : ?> <div id="centerbottommodule"> <div class="inner clearfix"> <jdoc:include type="modules" name="centerbottom" style="xhtml" /> </div> </div> <?php endif; ?> </div> </main> <?php if ($this->countModules('sidebar-b')) : ?> <aside id="right" class="column column2"> <?php if ($this->countModules('sidebar-b')) : ?> <div class="inner clearfix"> <jdoc:include type="modules" name="sidebar-b" style="xhtml" /> </div> <?php endif; ?> </aside> <?php endif; ?> <div class="clr"></div> </div> </div> <?php if ($this->countModules('mainbottom')) : ?> <div id="mainbottommodule"> <div class="inner clearfix"> <jdoc:include type="modules" name="mainbottom" style="xhtml" /> </div> </div> <?php endif; ?> </div> </div> <div class="clr"></div> </div> </div> </div> </div>

You can see for the row called 'modulestop' it already has the php query outside the section creation, and it prevents it from creating the ::before and ::after if there is no content.
All of the other content is already created in this way.
If you look at the code for the #left column (I have renamed it 'sidebar-a'), your code does not actually create the column (aside) unless there is content for it, so it is actually perfect:
Code:
<?php if ($this->countModules('sidebar-a')) : ?> <aside id="left" class="column column1"> <?php if ($this->countModules('sidebar-a')) : ?> <div class="inner clearfix"> <jdoc:include type="modules" name="sidebar-a" style="xhtml" /> </div> <?php endif; ?> </aside> <?php endif; ?>

The only thing I can think of here is that the wrapper itself (and any ::before or ::after images/settings) is created whether or not it has anything in it.

If the wrapper could be wrapped in a PHP if query, then that would fix this issue. The IF query would need to grab all of the available positions within the wrapper though, so in the above case it would have to query:
Code:
<?php if ($nbmodules13) or ('sidebar-a') or ('maintop') or ('centertop') or ('sidebar-b') or ('centerbottom') or ('mainbottom'); ?> <div id="wrapper"> ..... </div> <?php endif; ?>

My php sucks, so it may need to use '($this->countModules('sidebar-a'))' instead...

It would basically be saying 'hey, there is nothing published in any of the positions inside this wrapper, so I am not going to bother creating the wrapper'

As I already said, your code INSIDE the wrapper is perfect as each section is queried before creation, its just that the wrapper itself needs wrapped in a query.
Last Edit:8 years 8 months ago by Boradan
Last edit: 8 years 8 months ago by Boradan.

Please Log in or Create an account to join the conversation.

Replied by ced1870 on topic background images showing even when no module

Posted 8 years 8 months ago #29462

My php sucks, so it may need to use '($this->countModules('sidebar-a'))' instead...

don't worry, I understand :)
this is exactly what I have told in my previous post, I understand what you mean. But here in your example you have just few positions, some templates have many many more positions in one wrapper. this is possible, but imagine how long would be the condition :(

I have noted your request, and I will see how to implement this in a future version
thank you

Joomlack Webmaster and Developer

by ced1870

Please Log in or Create an account to join the conversation.

Replied by Boradan on topic background images showing even when no module

Posted 8 years 8 months ago #29470
haha ;)
There was me thinking I was overdoing it with module positions inside wrappers ;)
by Boradan

Please Log in or Create an account to join the conversation.

Replied by ced1870 on topic background images showing even when no module

Posted 8 years 3 months ago #31938
Hi
few words to tell you that I have added this feature in the new version 3.4.8 :)
Don't hesitate to test and tell me if this works for you
CEd

Joomlack Webmaster and Developer

by ced1870

Please Log in or Create an account to join the conversation.

Time to create page: 0.640 seconds

Fast and powerful creation, customizable and responsive.

Read More

We have 382 guests and no members online