tags:

views:

1220

answers:

4

I need to modify the HTML structure of a joomla module. I would like to create my custom module where I need to display the title below its content. This is the present HTML which is default format (rounded):

<div class="module_clipon">
 <div>
   <div>
     <div>
        <h3>Right Module</h3>
        <p>This is the content</p>      
     </div>
   </div>
 </div>
</div>

I need the above HTML to be like :

<div class="module_clipon">
    <p>This is the content</p>
    <h3>This is the title</h3>
</div>

Basically to bring the title below the module content. What would be the way to manipulate the HTML of a module in Joomla. I believe it is possible by using the modChrome. If anybody has a simple to implement solution, please help.

+1  A: 

You will indeed want to handle this through custom module chrome. Within the folder of your template, create an html folder if one does not already exist. Within this folder, create the file modules.php. Then fill it with this code:

<?php 

defined( '_JEXEC' ) or die;

function modChrome_titleonbottom( $module, &$params, &$attribs ) 
{
  echo '<p>' . $module->content . '</p>';
  echo '<h3>' . $module->title . '</h3>';
}

Finally, go back to your template to apply this chrome to your module position:

<div class="module_clipon">
    <jdoc:include type="modules" name="left" style="titleonbottom"/>
</div>

Use whatever module position name you need in the name parameter. Notice that the style parameter matches the modChrome_ function name.

For more info: http://docs.joomla.org/What_is_module_chrome%3F http://docs.joomla.org/Applying_custom_module_chrome

jlleblanc
Thanks jlleblanc, your response is helpful. But I need to have other modules in the same module position with default rounded layout (4 divs wrapping) above and below it. any guess how to make this happen ?
Cruising2hell
+1  A: 

@Cruising2hell if you want to have alternative module layouts on the same position have you tried using module suffix params?. Like so..

<?php 

defined( '_JEXEC' ) or die;

function modChrome_titleonbottom( $module, &$params, &$attribs ) 
{
  switch($params->get('moduleclass_sfx')) :
     //My type of module 
     case 'titleonbottom':
       echo '<p>'. $module->content . '</p>';
       echo '<h3>' . $module->title . '</h3>';
     break;
     default:
     //Normal
       echo '<h3>' . $module->title . '</h3>';
       echo '<p>'. $module->content . '</p>';
     break; 
   endswitch;

}
dr.stonyhills
Thanks very much ... that solves what I need .. Although I have another query, is it possible to have a similar solution for article component. If i can have different HTML layouts for articles to implement a 'portfolio' kind of page in Joomla to display the projects, while have regular articles on one page. I m not sure, pls suggest whats the best solution to have a projects page which would display projects in an easy manner. It must include Thumbnail, project detail and some client info.
Cruising2hell
If you are linking to the project pages with a menu, There is also a sfx for pages, you can play about with, just switch $this->params->get( 'pageclass_sfx' ); but make sure u set the suffix in your menu. Not the best of solutions! but will let u know if i come up with something better!
dr.stonyhills
A: 

i cannot call it a problem.

go to your main css file and insert this code :

.module_clipon h3 { position: absolute; margin-top: 100px; }

/* put a right height value where your h3 module header reach the bottom of the module content */

:-)

Noli Aux
A: 

i cannot call it a problem.

go to your main css file and insert this code :

.module_clipon h3 { 
      position: absolute; 
      margin-top: 100px; 
 }

/* put a right height value where your h3 module header reach the bottom of the module content */

:-)

Noli Aux