Keyword

[SOLVED] Add a Module position to K2 Template do it better?

  • Erwin Dicker
  • Erwin Dicker's Avatar Topic Author
  • Offline
  • Senior Member
More
10 years 9 months ago - 10 years 9 months ago #115683 by Erwin Dicker
hi

i found two solutions

1. module anywhere and add this to the item.php
{modulepos test}

2.add this to item.php
< ?php $module = JModuleHelper::getModules('test');
echo JModuleHelper::renderModule($module[0]);? >





but how can i just put this in it and works ?

< jdoc:include type="modules" name="test" style="xhtml" / >

Please Log in or Create an account to join the conversation.

  • Yiota
  • Yiota's Avatar
  • Visitor
10 years 9 months ago #115684 by Yiota
Try this:
<?php foreach (JModuleHelper::getModules('test') as $module) {				
echo JModuleHelper::renderModule($module, array('style' => 'xhtml'));		
}?>

Please Log in or Create an account to join the conversation.

More
10 years 1 month ago #115685 by Nikos
Hello,
Where should I put this code? Everywhere I like into item.php file? What if my position called belowcontent then it would be like this?
Log in  or Create an account to join the conversation.

More
10 years 1 month ago #115686 by Lefteris
@Nikos

If you put this code in your page ( K2 item.php layout for example ) then the module position "belowcontent" will be loaded in every item page. In that case the menu assignment in module page has no effect. You can also assign this module to "All Pages". This will not affect your site if this position is not loaded in your main template file.

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

More
10 years 1 month ago - 10 years 1 month ago #115687 by Nikos

Lefteris Kavadas wrote: @Nikos

If you put this code in your page ( K2 item.php layout for example ) then the module position "belowcontent" will be loaded in every item page. In that case the menu assignment in module page has no effect. You can also assign this module to "All Pages". This will not affect your site if this position is not loaded in your main template file.


So the module position is loading but what about the module itself? What more do I have to do than publishing it in belowcontent position without any assignment?

Please Log in or Create an account to join the conversation.

More
10 years 1 month ago #115688 by Lefteris
Publish the module. Also assign it to "All Pages" just in case this affects the output. If you have this position to your site also, then create another position and put the module there.

JoomlaWorks Support Team
---
Please search the forum before posting a new topic :)

Please Log in or Create an account to join the conversation.

More
10 years 1 month ago - 10 years 1 month ago #115689 by Nikos
I don't want it to be shown in all pages only in item page. In your opinion you suggest me to create another module position into k2 item.php file and publish the module in all pages? How can I do that just by entering

< jdoc:include type="modules" name="belowcontent_item" style="xhtml" / >

is that enough and then run the script above?
Do I have to change the xml template file?

Please Log in or Create an account to join the conversation.

More
10 years 1 month ago #115690 by Nikos
yes it worked I just wrote at the end of the item.php
Log in  or Create an account to join the conversation.