Use Module Title as link in Joomla 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="" />
  3. Save your XML file.
  4.  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 functionfunction 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;
    }
  5.  Now you have link area in your module basic parameter add your link 🙂

Conclusion – It’s very simple hack or trick in joomla I hope in joomla! 3.0 joomla add this feature by default.

Advertisements

Posted on January 3, 2013, in Web Dev and tagged . Bookmark the permalink. Leave a comment.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: