Intro

Linked Titles in Joomla! 1.5 Modules

Attention: open in a new window. PDFPrintE-mail

Blog

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!)

Trackback(0)
Comments (17)Add Comment
...
written by Scott Binnie, May 19, 2010
Carolyn:

The index file to be edited is "[your_joomla_site]/templates/ja_purity/index.php"
report abuse
vote down
vote up
Votes: +0
Last step
written by Carolyn Phillips, May 11, 2010
Not working for me, and I'm so BUMMED because I NEED IT smilies/smiley.gif Followed exactly except the last step... not sure where to put that line of code! Thanks for your help!
report abuse
vote down
vote up
Votes: +0
index.php
written by Carolyn Phillips, May 11, 2010
My index file has only one line! I'm using ja purity... do I edit the html in the admin? I'll try that...
report abuse
vote down
vote up
Votes: +0
Re: Header Animation
written by Scott Binnie, April 05, 2010
It's called 3D FLASH CAROUSEL and it's from www.webpsilon.com/joomla-extensions/
report abuse
vote down
vote up
Votes: +0
Header Animation
written by Semakula Abdul, March 21, 2010
Hullo, sorry may be off topic, but i just need to know the module or script you used for the awesome pic animation on your header... regards
report abuse
vote down
vote up
Votes: +0
Thank you!
written by Johanna, March 16, 2010
Thanks so much for this tutorial! Really don't get why this isn't an option in Joomla in the first place, but never mind, this works a treat smilies/smiley.gif
report abuse
vote down
vote up
Votes: +0
TY for the info!
written by mgerling, March 06, 2010
Don't understand why this isn't a standard feature in Joomla but I do appreciate the walk through! This worked perfectly on all modules I've altered so far!
report abuse
vote down
vote up
Votes: +0
...
written by Fabrice Baro, March 02, 2010
Reaplce the previously added function in module.php by this one:
function modChrome_linkTitle($module, &$params, &$attribs)
{
$headerLevel = isset($attribs['headerLevel']) ? (int) $attribs['headerLevel'] : 3;
if (!empty ($module->content)) : ?>
report abuse
vote down
vote up
Votes: +0
Title not displayed if "Title link URL" not set
written by Fabrice Baro, March 02, 2010
You did a good job summerizing the thread on the joomla forum. http://forum.joomla.org/viewto...2&t=289650.
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" %$?$/&*&)
report abuse
vote down
vote up
Votes: +0
THank you
written by ADrian, February 20, 2010
Hello,

Thanks a bunch for this! It worked like a charm!
report abuse
vote down
vote up
Votes: +0
Thank you!
written by Marius, November 06, 2009
Hi Scott,

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
report abuse
vote down
vote up
Votes: +0
removes module titles that weren't modified
written by Brian Peat, October 22, 2009
The problem I have with this trick is that if I have a module in the same position, the title of the unmodified module disappears.
report abuse
vote down
vote up
Votes: +0
Re: Module copies
written by Branko, October 02, 2009
I found.
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.
report abuse
vote down
vote up
Votes: -1
Re: Module copies
written by Scott Binnie, September 28, 2009
I'm not sure if it has anything to do with your problem, but there could be an issue of copying a module rather than creating a new instance of it.

Other than that, you can check your jos_modules database table to make sure the link is there.

Also, remember to identify the [jdoc:include type="modules" name="X" style="Y"] tags in the template/index.php file, and change the "Y" to whatever NAME you used as "function modChrome_NAME($module, &$params, &$attribs)" in the modules.php file.
report abuse
vote down
vote up
Votes: +0
Re: Module copies
written by Branko, September 28, 2009
Thank you for your time. You can see my temporary site: http://lifestyle2.enaa.com/. On bootom left is JA Bulletin module named 'Erotične zgodbe'. In the middle bottom is a copy of same module named 'Ljubezenske zgodbe', which does not display link.
report abuse
vote down
vote up
Votes: +0
Re: Module copies
written by Scott Binnie, September 28, 2009
I haven 't tried it with JA Bulletin, but as you can see on the homepage of this site, it's working with 3 separate Jumi modules. Could you be a bit more specific about what's not working?

Scott
report abuse
vote down
vote up
Votes: +0
Module copies
written by Branko, September 28, 2009
Unfortunatly it does not work if you have module copies. Probably missing some Module unique ID or simmilar. I use JA Bulletin for different categories but it does not work. Can you fix it? Thanx.
report abuse
vote down
vote up
Votes: +0

Write comment
quote
bold
italicize
underline
strike
url
image
quote
quote
smile
wink
laugh
grin
angry
sad
shocked
cool
tongue
kiss
cry
smaller | bigger

security code
Write the displayed characters


busy

Share it!

x