Wednesday, 17 July 2013

Use Module Title as link in Joomla 1.6 , 1.7 , 2.5

1 – Open your module .xml file  example - modules/mod_articles_news/mod_articles_news.xml
2 –  Add the following line between the first set of <fieldset name=”basic”></fieldset> tags
<field name="title_link" type="text" default="" label="Title link" description="" />
Save your XML file.
3 – Now go to templates/system/html/modules.php open it & find the xhtml function or find this line “ xhtml (divs and font headder tags) ” here you can find this function
function modChrome_xhtml($module, &$params, &$attribs)
{
 if (!empty ($module->content)) : ?>
  <div class="moduletable<?php echo htmlspecialchars($params->get('moduleclass_sfx')); ?>">
  <?php if ($module->showtitle != 0) : ?>
   <h3><?php echo $module->title; ?></h3>
  <?php endif; ?>
   <?php echo $module->content; ?>
  </div>
 <?php endif;
}

& replace with
function modChrome_xhtml($module, &$params, &$attribs)
{
 if (!empty ($module->content)) : ?>
  <div class="moduletable<?php echo htmlspecialchars($params->get('moduleclass_sfx')); ?>">
  <?php if ($module->showtitle != 0) : ?>
   <?php $title_link = $params->get('title_link'); ?>
   <h3><?php if($title_link) { ?> <a href="<?php echo $params->get('title_link');  ?>"> <?php } ?><?php echo $module->title; ?><?php if($title_link) { ?></a><?php } ?></h3>
  <?php endif; ?>
   <?php echo $module->content; ?>
  </div>
 <?php endif;
}

4 – now you have link area in your module basic parameter add your link  :)
Conclusion - Its very simple hack  or trick in joomla i hope in joomla! 3.0 joomla add this feature by default :) if you get any kind of issue or can’t get right result kindly leave your comment or contact with me thanks

4 comments:

  1. Very good article. thanks for sharing.. SEO Services

    ReplyDelete
  2. Will this work on Joomla 3.x?

    ReplyDelete
  3. A khánh ơi, em làm theo nhưng không được. Phần backend thì có hiện để add link, nhưng frontend thì không có gì anh ạ. E dùng bản Joomla 2.5.24. A giúp e với

    ReplyDelete