How to include modules in Section/Content Description (for Joomla 1.5.x)?
Written by kksou   
Sunday, 20 April 2008

This is in response to Filipe Torres's post titled "How to include modules in section/category description".

The standard mosloadposition plugin that comes bundled with the original Joomla 1.5.x installation only allows you to include modules in content items.

This article shows you how to include modules in Section/Category description. You can see a live example here.


Note: Please refer to the following post in Joomla forum:

http://forum.joomla.org/viewtopic.php?p=1295599#p1295599

I think starting Joomla 1.5.3, you do not need the fix as outlined in steps 4 and 5. The section/category description now gets processed by the content plugins by default.

Solutions

  1. Download and install. First you need to download and install the plugin loadmodule for Section/Category Description.

  2. Publish the plugin. Go to Extensions menu, select Plugin Manager and make sure the plugin is enabled.
  3. Add Trigger for Category Description. In the original Joomla installation, there is no trigger during the display of Category description. When there is no trigger, none of the mambot or plugin gets called. In order for Joomla to call the new plugin that we have just installed to include a module, we need to add a trigger.
    1. Go to the folder <Joomla root folder>/components/com_content/views/category, you will see a file called view.html.php.
    2. Open this file view.html.php in your favorite editor.
    3. Go to around Line 39. In the function display(), add the four lines highlighted in yellow near the beginning of the function as follows:
    4. class ContentViewCategory extends ContentView
      {
          function display($tpl = null)
          {
              global $mainframe, $option;
      
              // Initialize some variables
              $user		=& JFactory::getUser();
              $uri 		=& JFactory::getURI();
              $document	=& JFactory::getDocument();
              $pathway	=& $mainframe->getPathway();
      
              $category	=& $this->get('Category');
              $dispatcher	=& JDispatcher::getInstance();
              JPluginHelper::importPlugin('content');
              $results = $dispatcher->trigger('onBeforeDisplayTitle', array (& $category));
      
              // Get the menu item object
              $menus = &JSite::getMenu();
              $menu  = $menus->getActive();
      
    5. Save and close this file.

  4. Add Trigger for Section Description. If you also want to include modules for Section Description, you also need to add a trigger as explained above.
    1. Go to the folder <Joomla root folder>/components/com_content/views/section, you will see a file called view.html.php.
    2. Open this file view.html.php in your favorite editor.
    3. Go to around Line 36. In the function display(), add the four lines highlighted in yellow near the beginning of the function as follows:
    4. class ContentViewSection extends ContentView
      {
          function display($tpl = null)
          {
              global $mainframe, $option;
      
              // Initialize some variables
              $user		=& JFactory::getUser();
              $document	=& JFactory::getDocument();
      
              $section	=& $this->get('Section');
              $dispatcher	=& JDispatcher::getInstance();
              JPluginHelper::importPlugin('content');
              $results = $dispatcher->trigger('onBeforeDisplayTitle', array (& $section));
      
              // Get the page/component configuration
              $params = &$mainframe->getParams();
      
              // Request variables
              $limit = JRequest::getVar('limit', $params->get('display_num'), '', 'int');
              $limitstart = JRequest::getVar('limitstart', 0, '', 'int');
      
    5. Then go to around Line 87, also in the function display(), add the four lines highlighted in yellow as follows. (Note: this one takes care of the case in which you have modules embedded in each of the category description):
    6. class ContentViewSection extends ContentView
      {
          function display($tpl = null)
          {
                  .
                  .
                  .
      
              //add alternate feed link
              if($params->get('show_feed_link', 1) == 1)
              {
                  $link	= '&format=feed&limitstart=';
                  $attribs = array('type' => 'application/rss+xml', 'title' => 'RSS 2.0');
                  $document->addHeadLink(JRoute::_($link.'&type=rss'), 
                      'alternate', 'rel', $attribs);
                  $attribs = array('type' => 'application/atom+xml', 'title' => 'Atom 1.0');
                  $document->addHeadLink(JRoute::_($link.'&type=atom'), 
                      'alternate', 'rel', $attribs);
              }
      
              $dispatcher	=& JDispatcher::getInstance();
              JPluginHelper::importPlugin('content');
      
              for($i = 0; $i < count($categories); $i++)
              {
                  $category =& $categories[$i];
                  $category->link = JRoute::_('index.php?view=category&id='.
                      $category->slug);
      
                  $results=$dispatcher->trigger('onBeforeDisplayTitle', array(&$category));
              }
      
              if ($total == 0) {
                  $params->set('show_categories', false);
              }
      
    7. Save and close this file.

  5. That's it! You can now include a module inside a Section/Category description using the same method as outlined in How to include modules in Content item (for Joomla 1.5.x).


User reviews   Average user ratings:    4.5   (from 11 users)
  1. max
    June 11, 2008 4:06pm
    i have a question...

    I dont undestand i found the view.html.php but what about content.html.php?... i cant found this... so... y create this or where coul i foun it?...

  2. kksou
    June 11, 2008 5:47pm

    oops, it's a typo. Both should be view.html.php.

    Have fixed them in the document.

    Thanks for pointing this out.

    Regards,
    /kksou

  3. max
    June 12, 2008 6:11pm
    Tnks!

    Tnks a lot... so i have a new question, i can use {loadposition position} but when i use {loadmodule mod_namemodule} it dont do any thing just display the text {loadmodule mod_namemodule}... coul you explain me how could i do it?

  4. kksou
    June 13, 2008 2:44am

    Please refer to the following article which shows you how to set up a new module position. You have to use module position, not the name of the module.

    How to include modules in Content item (for Joomla 1.5.x)

    Regards,
    /kksou

  5. boreus
    July 18, 2008 4:05pm
    Seem to not working for me...

    I have J1.5.1. Passed all the steps from the manual, cheked many times...not working.
    http://www.edemvkrim.com/index.php?option=com_content&view=category&id=34&Itemid=54
    In the example i've installed Simple SlideShow and placed it in "left" position. There it works. But not in the section description.
    Help! Need this thing very much!

  6. boreus
    July 18, 2008 5:14pm

    But it works fine on localhost...

  7. kksou
    July 19, 2008 5:31am

    Hi Boreus,

    Have looked at your website.

    1. Some slideshow module will only allow one slide show per webpage. You may want to check this first.

    2. You shouldn't be using {loadposition left} in the section description. The module position "left" is the predefined position on the left. If you want to display a module in the section description, you have to create a new module position, e.g. user201. (Please refer to the article: How to include modules in Content item if you're not sure how to do this.) Then you need to publish the module to this position for the module to appear there.

    3. If your slideshow module supports displaying of slideshows in two module positions, then you have to create a duplicate of the slideshow module. Then you publish one in the "left" module position, and the other in the new module position you've created.

    4. Did you modify the view.html.php and add the trigger to call the plugin (as described above in this article)? It looks to me that the loadposition plugin is not called. You might want to double check this.

    Regards,
    /kksou

  8. boreus
    July 20, 2008 8:05am

    Hi, kksou,
    Thanx a lot for such a detailed description!
    Did all as you've told:
    Now the slideshow module is published only once in the "user201" position.
    Double checked view.html.php file, compared it with the one on localhost - the same thing, everything as in article above. Strangely enough, {loadposition user201} loads slideshow in the arcticle content just fine.
    Here it is: link
    What else should i check?
    It would be so incredible if it works out! The plugin is really awesome!

  9. Leo from UK
    September 21, 2008 3:31pm
    Excellent module but...

    I was hoping this would work out of the box for the categories in Virtuemart but alas no!

    I don't suppose anyone would have an idea how I would adapt it to do this??

    (thanks)

  10. nexus6it
    October 06, 2008 5:06am
    maybe a typo?

    have a nice day.
    in the articles has written:

    "# Add Trigger for Section Description. If you also want to include modules for Section Description, you also need to add a trigger as explained above.

    1. Go to the folder /components/com_content/views/section, you will see a file called view.html.php."

    in that file i found this around the lines 87:

    "//add alternate feed link
    if($params->get('show_feed_link', 1) == 1)
    {
    $link = '&format=feed&limitstart=';
    $attribs = array('type' => 'application/rss+xml', 'title' => 'RSS 2.0');
    $document->addHeadLink(JRoute::_($link.'&type=rss'), 'alternate', 'rel', $attribs);
    $attribs = array('type' => 'application/atom+xml', 'title' => 'Atom 1.0');
    $document->addHeadLink(JRoute::_($link.'&type=atom'), 'alternate', 'rel', $attribs);
    }

    $menus = &JSite::getMenu();
    $menu = $menus->getActive();

    // because the application sets a default page title, we need to get it
    // right from the menu item itself
    if (is_object( $menu )) {
    $menu_params = new JParameter( $menu->params );
    if (!$menu_params->get( 'page_title')) {
    $params->set('page_title', $section->title);
    }
    } else {
    $params->set('page_title', $section->title);
    }
    $document->setTitle( $params->get( 'page_title' ) );

    // Prepare section description
    $section->description = JHTML::_('content.prepare', $section->description);

    for($i = 0; $i < count($categories); $i++)
    {
    $category =& $categories[$i];
    $category->link = JRoute::_(ContentHelperRoute::getCategoryRoute($category->slug, $category->section).'&layout=default'); ""

    that is too different from the example.

    what error i did? is a normal installation

    Best regards
    N6

  11. kksou
    October 06, 2008 5:50am

    Hi N6,

    Please refer to the following post in Joomla forum:

    http://forum.joomla.org/viewtopic.php?p=1295599#p1295599

    I think starting Joomla 1.5.3, you do not need the above fix. The section/category description now gets processed by the content plugins by default.

    Regards,
    /kksou

Note: You have to be a registered member to leave a comment. Free registration here.

 
< Prev   Next >

Blog - Forum - Privacy Policy - Contact Us
Copyright © 2006-2009. kksou.com. All Rights Reserved