Tuesday, December 13, 2011

How can I add a new module position to a Joomla template?


Joomla templates always include a certain number of predefined module positions.
If you need an additional module position, to make an example let's name it user99, you have two different ways to add it to your template.
1) locate the file
[...]/templates/[template_name]/templateDetails.xml
[...] is the path to the folder where Joomla is installed.
[template_name] is obviously the name of the template you are modifying.
If your site is online use a FTP program to download the file to your PC. Open the file with a plain text editor and search for this part
<positions>
  <position>left</position>
  <position>right</position>
  <position>top</position>
  <position>breadcrumb</position>
  <position>user1</position>
  <position>user2</position>
  <position>user3</position>
  <position>user4</position>
  <position>debug</position>
  <position>syndicate</position>
</positions>
This is how this part of the templateDetails.xml file looks in beez template. In another template it won't be identical, hower you should find a number of positions between <position> and </position> all included between a pair of <positions> and </positions> .
Simply add your position to the list: at the top, at the bottom or in the middle it doesn't matter. For example
<positions>
  <position>left</position>
  <position>right</position>
  <position>top</position>
  <position>breadcrumb</position>
  <position>user1</position>
  <position>user2</position>
  <position>user3</position>
  <position>user4</position>
  <position>debug</position>
  <position>syndicate</position>
  <position>user99</position>
</positions>
Save the file and upload it to your website in the same location where you found it.
2) You can also create a new module position as soon as you need it i.e when you need to assign a module to it.
In Joomla backend go to Extensions -> Module Manager. Click on the module name you want to assign to a new position.
Module Manager. Create new module positionOn the next page you will find a Position field. It's a drop down list containing all available module positions. You can not only choose an existing position from the list, if you click inside the field you will see that you can write in it: enter user99.
Once pressed the Save button you will see that the module is now assigned to user99.

Module Manager. Module positions drop down listNot only, if you select another module from the list you will notice that user99 is now included in the module positions drop down list.
Whether you have followed method 1) or 2), come to this point you have created a new module position, however if you don't include it in the template, a module assigned to it will be invisible because Joomla doesn't know where to display its content.
To complete the work you need to modify the index.php file of your template.
Locate the file
[...]/templates/[template_name]/index.php
Open it with a plain text editor and add the following line where you want modules assigned to user99 position are rendered.
<jdoc:include type="modules" name="user99" style="xhtml" />

No comments:

Post a Comment

Thank you for your Comment....

Popular Posts