When you add new modules to position-7 in Protostar, the order of your modules might change. It may be that you wish to have a specific module that you wish to always have at the top. This could be something like important links, related articles, a menu or a search box.

You can go into Module Manager, filter for that position and resort them. The problem is that you may not wish to be doing this repeatedly or you may not catch that they got out of your desired order.

This article will go through how to create a new position then place it so it will always reside in the <div id="aside"> column but always be placed above the modules in position-7.

We will be editing two files, templateDetails.xml and index.php in your Protostar folder. If you copied the Protostar template using the proper steps in Template Manager and set the copy as the default, edit the files in the new folder. Always make backups of these files before editing the original files.

Create a new module position

To create a new module position, you must edit the templateDetails.xml file in the Protostar template folder.

Add this line within the <positions></positions> tags in templateDetails.xml:

<positions>
        <position>fixedrighttop</position>
        ...
</positions>

By doing this, the position name of fixedrighttop will now appear in the dropdown list of possible positions for the Modules. 

We now need to create a place for this position in.

Add the new position to index.php

For this example, we are placing the new position in the right column created by <div id="aside"> where position-7 is placed.

Now we need to edit and add new lines to index.php in the template's folder. Find these lines in index.php and add the text highlighted in yellow.

<?php if (($this->countModules('position-7')) || ($this->countModules('fixedrighttop'))) : ?>
    <div id="aside" class="span3">
        <!-- Begin Right Sidebar -->
        <jdoc:include type="modules" name="fixedrighttop" style="well" />
        <jdoc:include type="modules" name="position-7" style="well" />
    </div>
<?php endif; ?>

This new text will create the <div id="aside"> if there is a module assigned to either position-7 OR fixedrighttop. The module in fixedrighttop will always reside above any modules in position-7. Be sure to add the proper number of parenthesis.

Do the same for the left column

This method could be used for a module position in position-8, but target <div id="sidebar">.

Keep the module at the bottom of the others

This method could also be used for keep a module below other modules, for something like a login or other purposes. Simply put the <jdoc> line below the one for position-7.


Has BJ.Zemplate.com helped you with understanding Joomla?

If you would like to make a small contribution to help fund this resource, that would be great, but do not feel obligated in any way.

Donation Amounts


Still not finding a special topic?

Use Google's Search function below for search the content of bj.zemplate.com.