If you are working with Joomla, You have to know about Module Position because its basic functionality you have to use within a template. Sometimes we need to create a new module position in a Joomla template.Module Position is necessary to display modules into the template.
In Joomla, You have to know about Module Position because its basic feature you have to use within a template. even you need to add the new position for new Joomla site.Module Position is necessary to display modules into the template
There are two ways to load the modules in Template of Joomla.
- Without Conditions
- With conditions
First of all, To load Module without condition in template, you just need to add below line of code:
1 2 3 |
Conditional Module position is specifically useful when you want to have a different layout.Like on some specific condition, you want to load the module.
To load Module with the condition, you have to use if() statement of PHP before you load the module.
Let’s have a look how to count the number of a single module, you can execute a method like:
1 2 3 4 5 | if ($this->countModules(’module_position’)) : <jdoc:include type="modules" name"module_position" style="xhtml" /> endif; |
You can use the same method to count the multiple modules like this:
1 2 3 | $this->countModules('module_position1 + module_position2'); |
In above code, the countModules() function will help you determine enabled modules within a template reference on the current page.
I hope this post will help you. Don’t Forget to Follow us on Twitter or Subscribe us to Get the Latest Updates.
Comments (1)