How to create module titles that link directly to other content in Joomla! 1.5.
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.
Existing Browser Window
New Browser Window
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)) : ?>
if ($module->showtitle) :
if ($params->get('titleLink') !="") :
$destination="";
if ($params->get('titleLinkDestination') ==1) :
$destination=" target=\"_blank\"";
endif;
echo "get('titleLink')."\"".$destination.">".$module->title."";
endif;
endif;
echo $module->content;
?>
}
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.















