Intro
Linked Titles in Joomla! 1.5 Modules
Thursday, 20 August 2009
This exercise came about because I wanted some of the ScottBinnie.com Home page Module Titles to include embedded links directly to articles and components in the site. Although I happened to be using Jumi as the module source (the modules simply contained intro text and teasers), the principle used can be applied to almost any Joomla! 1.5 module.
Before continuing, I would like to credit "Ollvin" on the Joomla! Forums who submitted the basic ideas in his post re: "Link module title" from June, 2008. I made a couple of changes and enhancements to his concept.
In any case, in Jumi, here's how to create Linked Module Titles:
1.1 Open the file "your_joomla_folder/modules/mod_jumi/mod_jumi.xml" where all the parameters fields are stored. These are the parameters that appear in the right column of the menu module properties page. (found in the admin under "Extensions / Module_Manager / Your_Jumi_Module).
1.2 Copy and paste a new Spacer <param...> line at the bottom of but inside the first <PARAMS></PARAMS> section.
1.3 Add a new <param...> line beneath it the name "titleLink" (this will appear as the variable name in the database), "size = 97" (so you can see the full URL when you enter it), the label "Title link URL" and the description "PARAMLINKURL". The line should look like:
<param name="titleLink" type="text" size ="97" default="" label="Title link URL" description="PARAMLINKURL" />
1.4 Add the following <param...> lines immediately below the one you just entered. They will enable you to redirect the link to a new browser window if you want.
<param name="titleLinkDestination" type="list" default="0" label="Link Destination" description="PARAMLINKDESTINATION">
<option value="0">Existing Browser Window</option>
<option value="1">New Browser Window</option>
</param>
1.5 Save the file back to it's original location.
2. Edit your Jumi module properties in the Module Manager. You will now see 2 new fields called "Title link URL" and "Link Destination" on the right in the Basic properties. Enter the link to the URL you want, select the destination and then save the module. (By the way, if you are curious, you can go to your database admin, table jos_modules, your_menu line and look at the field params. You will see "titleLink: followed by the URL you entered" proceded by "titleLinkDestination: followed by a 0 or a 1".)
3.1 Check to see if the file "your_joomla_folder/templates/your_template/html/modules.php" exists. If the directory is there but the file isn't, copy the "your_joomla_folder/templates/system/html/modules.php" file to the directory. If the "/your_template/html/" directory doesn't exist, create it, and then do the file copy. Each function() {...} block enables you to apply specific styles to the "<jdoc:include type="modules" name="X" style="Y"/>" tags in your index.php template file.
3.1.a If you had to copy the file, make sure to open the NEW copy and delete any existing function blocks in it - they can't exist in both files without potentially causing an error
3.2 OK, now open the new copy or existing file and copy the following function block into it :
function modChrome_linkTitle($module, &$params, &$attribs)
{
$headerLevel = isset($attribs['headerLevel']) ? (int) $attribs['headerLevel'] : 3;
if (!empty ($module->content)) : ?>
<div class="moduletable<?php echo $params->get('moduleclass_sfx'); ?>">
<?php
if ($module->showtitle) :
if ($params->get('titleLink') !="") :
$destination="";
if ($params->get('titleLinkDestination') ==1) :
$destination=" target=\"_blank\"";
endif;
echo "<h".$headerLevel."><a href=\"".$params->get('titleLink')."\"".$destination.">".$module->title."</a></h".$headerLevel.">";
endif;
endif;
echo $module->content;
?>
</div>
<?php endif;
}
3.3 Save the file and open your "your_joomla_folder/templates/your_template/index.php" file. Identify the "<jdoc:include type="modules" name="X" style="Y"/>" tags that you wish to enable title linking, and change the "Y" to "linkTitle".
3.4 Save the file. Now (after refreshing your browser window) you should be able to click on the title and it will take you where you want to be taken. If not, make sure that you entered the link in the Module Properties screen in admin and saved it.
All that may be left (if as in my case, you needed different text colors for different module positions) would be to add a CSS_suffix to your CSS file as well as in the Module Properties (Advanced).
NOTE: To use this function for modules other than those using the Jumi code, you should simply have to modify the appropriate XML file in that module's directory.
| If you found this article answered your need, then I'd really appreciate it if you'd... (Cheers!) |

written by Carolyn Phillips, May 11, 2010
Followed exactly except the last step... not sure where to put that line of code! Thanks for your help!
written by Carolyn Phillips, May 11, 2010
written by Semakula Abdul, March 21, 2010
written by Johanna, March 16, 2010
written by mgerling, March 06, 2010
written by Fabrice Baro, March 02, 2010
function modChrome_linkTitle($module, &$params, &$attribs)
{
$headerLevel = isset($attribs['headerLevel']) ? (int) $attribs['headerLevel'] : 3;
if (!empty ($module->content)) : ?>
written by Fabrice Baro, March 02, 2010
However the title of modules is not displayed if "Title link URL" not set.
I added the "else :" and "echo..." lines to the module.php code. Works neatly.
else : // FAB: added because title wasn't displayed if "Title Link URL" is not set.
echo "".$module->title."";
See whole function in next post... ($%$?%?& "post too long" %$?$/&*&)
written by ADrian, February 20, 2010
Thanks a bunch for this! It worked like a charm!
written by Marius, November 06, 2009
Thank you for this tip! I really needed this! Now let's see if it works with a font replacement plugin, not just a simple text. If it works I'll post the link for a demo later.
Good job, thanks!
Marius
written by Brian Peat, October 22, 2009
written by Branko, October 02, 2009
In index.php of my template I changed line for User1 module, but I didn't do it also for User2. Now it works.
Thanks. Now you can delele our conversation.
written by Branko, September 28, 2009




















The index file to be edited is "[your_joomla_site]/templates/ja_purity/index.php"