Question

Im quite confused as to the nature of overrides, alternate layouts and styles in Joomla 3.2

I have a custom template I am developing for a specific site, it is not meant to be reused. It "hard codes" the header and footer onto the page (as they remain constant across the site), and provides 8 custom positions and a place for the component to load. All of this works fine.

I have a main menu item called events, and I want the blog component linked to that menu item to load in a different place than normal. The layout of the articles themselves can remain the same, only the place the show up needs to change, and only on this page.

Template index.php :

<div id="top">
  <nav>
    <div id="navcontainer">
      <jdoc:include type="modules" name="nav" style="xhtml" />
    </div>
  </nav>
  <div id="featured">
    <jdoc:include type="modules" name="featured" style="xhtml" />
  </div>
</div>
<div id="content">
  <div class="bc">
    <jdoc:include type="modules" name="before main articles"  style="xhtml" />
  </div>
  <div id="component">
    <jdoc:include type="component" style="xhtml" />
  </div>
</div>

Desired Override,Alternate,Style...?:

<div id="top">
  <nav>
    <div id="navcontainer">
      <jdoc:include type="modules" name="nav" style="xhtml" />
    </div>
  </nav>
  <div id="featured">
    <jdoc:include type="component" style="xhtml" />
  </div>
</div>
<div id="content">
  <div class="bc">
    <jdoc:include type="modules" name="before main articles"  style="xhtml" />
  </div>
  <div id="component">
    <jdoc:include type="modules" name="archived" style="xhtml" />
  </div>
</div>

Very small change which has very big implications on the page. I cant even figure out what kind of change to make, the docs I find are mostly joomla 1.5-2.5 and I cant be sure what's changed since then.

How would I change this in my template? Override, Alternate layout, or style?

Side note: I know its bad practice to put spaces in module position names. I am phasing them out.

Was it helpful?

Solution

  • Overrides and altenate layouts are used to change the default core output of a given component or module. So for example if you want to change how articles are displayed, this is the way to go. Basically this is done by copying the layouts into the html folder in your template.
  • Template styles are meant to change the appearance of the template itself (not the core outputs) depending on a menu item. So in your case you would add a parameter to your template which lets you define if the component comes last or on top. And then you can have one template style where this parameter is disabled and one where it is enabled. In the template you make the check and put the output accordingly.
  • Or you could copy the whole template and just use two templates instead of two styles. This depends how big the difference will be.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top