- Posts: 45
COMMUNITY FORUM
Module Position in K2 Template
- WebHelpUS
- Topic Author
- Offline
- Senior Member
Less
More
7 years 3 weeks ago #165049
by WebHelpUS
Module Position in K2 Template was created by WebHelpUS
Can you add module positions to a K2 template?
Please Log in or Create an account to join the conversation.
- william white
- Offline
- Platinum Member
Less
More
- Posts: 3722
7 years 3 weeks ago #165054
by william white
Replied by william white on topic Module Position in K2 Template
I dont think this will work because it will probably confuse some process but see here:
docs.joomla.org/Declaring_module_positions
Add a position in the template xml file
add the include statement into the override
assign a module to the position
test it
docs.joomla.org/Declaring_module_positions
Add a position in the template xml file
add the include statement into the override
assign a module to the position
test it
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
- Offline
- Platinum Member
Less
More
- Posts: 15920
7 years 3 weeks ago #165091
by Krikor Boghossian
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Replied by Krikor Boghossian on topic Module Position in K2 Template
Yes, you can the same way you would modules outside of Joomla!'s index.php file using Joomla!'s module helper. You need to consult Joomla!'s API for this.
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.
- Ronny Van Der Borght
- Offline
- Senior Member
7 years 3 weeks ago #165094
by Ronny Van Der Borght
Replied by Ronny Van Der Borght on topic Module Position in K2 Template
I do this all the time, in fact it gives you the ability to have real template variations depending on k2 categories.
This is how it's done:
Where 'sidebar' is the module position's name.
This is how it's done:
<?php
// get document
$doc = JFactory::getDocument();
$renderer = $doc->loadRenderer( 'modules' );
$style = array( 'style' => 'raw' ); // you can change raw to other styles
if ($doc->countModules('sidebar') > 0) {
echo $renderer->render('sidebar', $style, null);
}
?>
Where 'sidebar' is the module position's name.
Please Log in or Create an account to join the conversation.
- Nadal Kumar
- Offline
- Junior Member
Less
More
- Posts: 28
7 years 3 weeks ago #165095
by Nadal Kumar
Replied by Nadal Kumar on topic Module Position in K2 Template
It's much simpler to use JHTML with content.prepare then implement the core loadposition plugin.
A simple one liner placed anywhere in item.php
If using earlier Joomla versions (2.5.x and below), you will need to import the plugin helper class
Then any module added to position k2pages will render in the K2 template. This method is applicable in any content display file, so it can be used in category view.
A simple one liner placed anywhere in item.php
<?php echo JHtml::_('content.prepare', '{loadposition k2pages,xhtml}'); ?>
If using earlier Joomla versions (2.5.x and below), you will need to import the plugin helper class
<?php JPluginHelper::importPlugin('content');
echo JHtml::_('content.prepare', '{loadposition k2pages,xhtml}'); ?>
Then any module added to position k2pages will render in the K2 template. This method is applicable in any content display file, so it can be used in category view.
Please Log in or Create an account to join the conversation.
- Krikor Boghossian
- Offline
- Platinum Member
Less
More
- Posts: 15920
7 years 2 weeks ago #165210
by Krikor Boghossian
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Replied by Krikor Boghossian on topic Module Position in K2 Template
Sorry to burst in, as Nadal explais, this is the optimal solution but remember to use overrides (if you are not already doing so)
getk2.org/documentation/tutorials/174-templating-with-k2-and-the-concepts-of-sub-templates
getk2.org/documentation/tutorials/174-templating-with-k2-and-the-concepts-of-sub-templates
JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)
Please Log in or Create an account to join the conversation.