Link module title

This forum is for general questions about extensions for Joomla! version 1.5.x.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
Locked
ollvin
Joomla! Apprentice
Joomla! Apprentice
Posts: 8
Joined: Sat Apr 19, 2008 9:37 am

Link module title

Post by ollvin » Sun May 04, 2008 4:53 pm

Hello,
I'm trying to put a link in main menu module title. Can I achieve that with a simple trick (I didn't see anything in menus options) or an extension ?
I can't use simple multi-level menu (with the parent fonction) with only css design because I need templates/system/html/modules.php file xhtml customisation to add all xhtml elements needed for my already built full css pop-out menu working (especially for IE - always IE : standard multi-levels ul li lists can't achieve that).
I looked at some complete menu extensions like lxMenu which could do that but, as I said, my template is already built (comming from my static html site previous version), so wouldn't like to flush all my cross-browsers-hard-design and have to recode all that from scratch, dealing with someone else's big, full-featured (and "code-full") script just for that little title-link purpose.
Suggestions ? Can some Joomler help a newbie on this Joomla-Planet ?

ollvin
Joomla! Apprentice
Joomla! Apprentice
Posts: 8
Joined: Sat Apr 19, 2008 9:37 am

Re: Link module title

Post by ollvin » Tue May 13, 2008 5:24 pm

It's ok.
Someone on Joomla.fr gave me a great tip to add any personal input to the backend.
I simply had a PARAM to the mod_mainmenu.xml ; then I can add my URL in module admin and get it in templates/mytemplate/html/modules.php with $params->get('titleLink'). Fantastic!

User avatar
dorjano
Joomla! Explorer
Joomla! Explorer
Posts: 432
Joined: Tue Aug 30, 2005 11:26 am
Location: Slovenia
Contact:

Re: Link module title

Post by dorjano » Wed Jun 04, 2008 10:50 am

Hi ollvin
could you be more specific please. I too had once this requirement but I solved it differently. Would be nice if you could describe your solution in more detail.
D.
Moderator of Slovenian Forum

ollvin
Joomla! Apprentice
Joomla! Apprentice
Posts: 8
Joined: Sat Apr 19, 2008 9:37 am

Re: Link module title

Post by ollvin » Wed Jun 04, 2008 2:44 pm

Ok. Let's be more "specific". (That's for J!1.5, I don't know if this was part of previous versions) Don't pay attention to approximativ labels, that's my own translation (my Joomla! language is French).
Open the file your_joomla_folder/modules/mod_mainmenu/mod_mainmenu.xml where are stored all parameters fields you can find in the right column, in a menu module properties page in Joomla admin (Extensions/Module manager/Your menu).
You can add a <PARAM ...> line anywhere you want with a new name (variable name in the database) and an intelligible label (like "the stuff I did some day", hum...) (each <PARAMS></PARAMS> section is a conterner group of parameters in the admin, like Module parameters, Advanced parmeters...). I choosed to put my own parameter at the end of the first contener because it's displayed first when you open your module page (Be lazy :D). Like this :

Code: Select all

	<params>
		<param name="menutype" type="mos_menu" default="" label="Menu Name" description="The name of the menu (default is mainmenu)" />
		<param name="menu_style" type="list" default="list" label="Menu Style" description="The menu style">
			<option value="list">List</option>
			<option value="vert_indent">Legacy - Vertical</option>
			<option value="horiz_flat">Legacy - Horizontal</option>
			<option value="list_flat">Legacy - Flat List</option>
		</param>
		<param name="@spacer" type="spacer" default="" label="" description="" />
		<param name="startLevel" type="text" default="0" size="5" label="Start Level" description="PARAMSTARTLEVEL" />
		<param name="endLevel" type="text" default="0" size="5" label="End Level" description="PARAMSTOPLEVEL" />
		<param name="showAllChildren" type="radio" default="0" label="Always show submenu items" description="PARAMSHOWSUBMENUITEMS">
			<option value="0">No</option>
			<option value="1">Yes</option>
		</param>
		<param name="@spacer" type="spacer" default="" label="" description="" />
		<param name="window_open" type="text" default="" label="Target Position" description="PARAMTARGETPOSITION" />

<!-- HERE IS A BRAND NEW PARAM -->

	    <param name="titleLink" type="text" default="" label="Title link URL" description="PARAMLINKURL" />

<!-- END OF THE BRAND NEW PARAM -->
	

</params>
Save and upload your file and go to a menu module properties in the Module manager : tada! there's a nice field "Title link URL" on the right. Put any URL coming out of your mind in it and save.

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 can see a line like this one :

Code: Select all

titleLink=hihihi.com
(That's Walt Disney's secret postmortem blog... Chht! Don't tell anyone)
Magic ! Your URL is now stored in the database.

So. Let's come back to our J! trick.
Open templates/system/html/modules.php : you can see one function () for each style option available when you insert a <jdoc:include type="modules" name="X" style="Y"/> tag in your index.php template file.
You could modify the XHTML one but it's not really good if you what to keep that normal option for any other purpose than your "title linked" menu.
Let's add a new option.
First we're going to put it in our own my_template folder to be more flexible later, (and J! standard compliant, of course...). Create a html/ folder in your template folder and copy the modules.php file there : templates/my_template/html/modules.php
Open this new copy and delete all function () blocks (they can't be set twice - in system folder and in your_template folder - this causes an error) or keep just the XHTML one to modify it. Give the function an other name. You can add all your esoteric html around <?php ?> place holders and - finally - add the magic place holder <?php echo $params->get('titleLink'); ?> to output your URL in some < a href=""> attribute. Like this :

Code: Select all

function modChrome_XHTMLlinkedMenu($module, &$params, &$attribs)
{
	if (!empty ($module->content)) : ?>
	   <div class="TitleLinkedMenu">	
                        <?php if ($module->showtitle != 0) : ?>		
	            <h3><a href="<?php echo $params->get('titleLink'); ?>"><?php echo $module->title; ?></a></h3>
                        <?php endif; ?>
                        <div class="TitleLinkedMenuContent">
                           <?php echo $module->content; ?>
                        </div>
                    </div>

	<?php endif;
}
Save and upload your file.

Then, don't forget to call your menu with the good jdoc tag style in your index.php template file : <jdoc:include type="modules" name="X" style="XHTMLlinkedMenu"/>

Well, uff... :geek: Enough details ?

User avatar
dorjano
Joomla! Explorer
Joomla! Explorer
Posts: 432
Joined: Tue Aug 30, 2005 11:26 am
Location: Slovenia
Contact:

Re: Link module title

Post by dorjano » Wed Jun 04, 2008 8:09 pm

wow nice trick! Excellent it works almost perfectly. There is just a little aesthetic issue (see picture). But could be easily avoided with some play with 0 an 1 in

Code: Select all

 <?php if ($module->showtitle != 0) : ?> 

Thanks Ollvin, grate tutorial ;)

Cheers,
Dorjano
You do not have the required permissions to view the files attached to this post.
Moderator of Slovenian Forum

ollvin
Joomla! Apprentice
Joomla! Apprentice
Posts: 8
Joined: Sat Apr 19, 2008 9:37 am

Re: Link module title

Post by ollvin » Thu Jun 05, 2008 8:12 am

I don't understand why your title is displayed twice. <?php echo $module->title; ?> should output the title (one occurence in my code) and <?php echo $module->content; ?> the... content (links only).
Maybe J! version...
What is the source code for this result ? J! should output links as an unordered list (ul li)...

User avatar
dorjano
Joomla! Explorer
Joomla! Explorer
Posts: 432
Joined: Tue Aug 30, 2005 11:26 am
Location: Slovenia
Contact:

Re: Link module title

Post by dorjano » Thu Jun 05, 2008 1:31 pm

Hmmm. I just use copy-paste from your code. Nothing more and nothing less.
I'm using fresh J! 1.5.2 with the default tempalte ( rhuk_milkyway).
D.
Moderator of Slovenian Forum

ollvin
Joomla! Apprentice
Joomla! Apprentice
Posts: 8
Joined: Sat Apr 19, 2008 9:37 am

Re: Link module title

Post by ollvin » Fri Jun 06, 2008 9:28 am

Are you sure your menus modules are set on "list" menu style (param in the admin) to output ul content ( <?php echo $module->content; ?> ) ?
Again, what is the source code of this enigmatic display ?

User avatar
dorjano
Joomla! Explorer
Joomla! Explorer
Posts: 432
Joined: Tue Aug 30, 2005 11:26 am
Location: Slovenia
Contact:

Re: Link module title

Post by dorjano » Fri Jun 06, 2008 7:37 pm

As I said, I didn't add nothing more and nothing less. Look at attached pix. List is ON (A), well the only difference it that I use Slovenian transaltion (B).
Look at the code:
mod_mainmenu.xml

Code: Select all

	<params>
		<param name="menutype" type="mos_menu" default="" label="Menu Name" description="The name of the menu (default is mainmenu)" />
		<param name="menu_style" type="list" default="list" label="Menu Style" description="The menu style">
			<option value="list">List</option>
			<option value="vert_indent">Legacy - Vertical</option>
			<option value="horiz_flat">Legacy - Horizontal</option>
			<option value="list_flat">Legacy - Flat List</option>
		</param>
		<param name="@spacer" type="spacer" default="" label="" description="" />
		<param name="startLevel" type="text" default="0" size="5" label="Start Level" description="PARAMSTARTLEVEL" />
		<param name="endLevel" type="text" default="0" size="5" label="End Level" description="PARAMSTOPLEVEL" />
		<param name="showAllChildren" type="radio" default="0" label="Always show submenu items" description="PARAMSHOWSUBMENUITEMS">
			<option value="0">No</option>
			<option value="1">Yes</option>
		</param>
		<param name="@spacer" type="spacer" default="" label="" description="" />
		<param name="window_open" type="text" default="" label="Target Position" description="PARAMTARGETPOSITION" />
		<!-- This is the code I add -Dorjano -->
		<param name="titleLink" type="text" default="" label="Naslov modula je ta URL" description="PARAMLINKURL" />
	    <!-- End of the new code -->
	</params>
and
modules.php
Note: the default rhuk_milkyway tempalte already has this file. I added your code at the end of existing one.

Code: Select all

<?php
/**
 * @version		$Id: modules.php 9764 2007-12-30 07:48:11Z ircmaxell $
 * @package		Joomla
 * @copyright	Copyright (C) 2005 - 2008 Open Source Matters. All rights reserved.
 * @license		GNU/GPL, see LICENSE.php
 * Joomla! is free software. This version may have been modified pursuant
 * to the GNU General Public License, and as distributed it includes or
 * is derivative of works licensed under the GNU General Public License or
 * other free or open source software licenses.
 * See COPYRIGHT.php for copyright notices and details.
 */

// no direct access
defined('_JEXEC') or die('Restricted access');

/**
 * This is a file to add template specific chrome to module rendering.  To use it you would
 * set the style attribute for the given module(s) include in your template to use the style
 * for each given modChrome function.
 *
 * eg.  To render a module mod_test in the sliders style, you would use the following include:
 * <jdoc:include type="module" name="test" style="slider" />
 *
 * This gives template designers ultimate control over how modules are rendered.
 *
 * NOTICE: All chrome wrapping methods should be named: modChrome_{STYLE} and take the same
 * two arguments.
 */

/*
 * Module chrome for rendering the module in a slider
 */
function modChrome_slider($module, &$params, &$attribs)
{
	jimport('joomla.html.pane');
	// Initialize variables
	$sliders = & JPane::getInstance('sliders');
	$sliders->startPanel( JText::_( $module->title ), 'module' . $module->id );
	echo $module->content;
	$sliders->endPanel();
}

 // This function was added for showing menu title as a link - by Ollvin FR -Dorjano
function modChrome_XHTMLlinkedMenu($module, &$params, &$attribs)
{
   if (!empty ($module->content)) :?>
      <div class="TitleLinkedMenu">   
                        <?php if ($module->showtitle != 0) : ?>      
               <h3><a href="<?php echo $params->get('titleLink'); ?>"><?php echo $module->title; ?></a></h3>
                        <?php endif; ?>
                        <div class="TitleLinkedMenuContent">
                           <?php echo $module->content; ?>
                        </div>
                    </div>

   <?php endif;
}

?>
and finally template's index.php (just a modul insertion part)

Code: Select all


. . . 
					<div id="area">
									<jdoc:include type="message" />

						<div id="leftcolumn">
						<?php if($this->countModules('left')) : ?>
							<!-- The Ollvin code -->
                            <jdoc:include type="modules" name="left" style="XHTMLlinkedMenu" />
                            <!-- Original code commented out
                            <jdoc:include type="modules" name="left" style="rounded" />
                            -->
						<?php endif; ?>
						</div>

						<?php if($this->countModules('left')) : ?>
						<div id="maincolumn">
						<?php else: ?>
						<div id="maincolumn_full">
						<?php endif; ?>
							<?php if($this->countModules('user1 or user2')) : ?>
								<table class="nopad user1user2">
									<tr valign="top">
										<?php if($this->countModules('user1')) : ?>
											<td>
												<jdoc:include type="modules" name="user1" style="xhtml" />
											</td>
										<?php endif; ?>
										<?php if($this->countModules('user1 and user2')) : ?>
											<td class="greyline">&nbsp;</td>
										<?php endif; ?>
										<?php if($this->countModules('user2')) : ?>
											<td>
												<jdoc:include type="modules" name="user2" style="xhtml" />
											</td>
										<?php endif; ?>
									</tr>
								</table>

								<div id="maindivider"></div>
							<?php endif; ?>

							<table class="nopad">
								<tr valign="top">
									<td>
										<jdoc:include type="component" />
										<jdoc:include type="modules" name="footer" style="xhtml"/>
									</td>
									<?php if($this->countModules('right') and JRequest::getCmd('layout') != 'form') : ?>
										<td class="greyline">&nbsp;</td>
										<td width="170">
											<jdoc:include type="modules" name="right" style="xhtml"/>
										</td>
									<?php endif; ?>
								</tr>
							</table>

						</div>
						<div class="clr"></div>
					</div>
					<div class="clr"></div>
				</div>
. . .
You do not have the required permissions to view the files attached to this post.
Moderator of Slovenian Forum

ollvin
Joomla! Apprentice
Joomla! Apprentice
Posts: 8
Joined: Sat Apr 19, 2008 9:37 am

Re: Link module title

Post by ollvin » Sat Jun 07, 2008 7:56 am

Well... I made a test with your code and I think I fixed your problem : simply remove the commented old code. That's a pure J! bug ! :D
It seems J! doesn't see comments and output code when it find a <Jdoc:> tag, even commented. This shouldn't matter : J! output normal code but, as it's commented, browsers don't display it.
But this double occurence strangely makes J! go mad : it also output the the whole second (commented) occurence of the <Jdoc:> in the content part of the first.
Don't ask why...
If you look at the outputed source code in your browser (that's what I meant asking the source code) you see something like this :

Code: Select all

  <div id="leftcolumn">
     <div class="TitleLinkedMenu">
		      				
		     <h3><a href="http://www.editions-theia.com">Livres et musique (Boutique)</a></3
		        <div class="TitleLinkedMenuContent">

###### Outputing whole rounded version in this content part (this comment wasn't in the code) #####

        		<div class="module">
			<div>
				<div>
					<div>
													<h3>Livres et musique (Boutique)</h3>
											<ul id="mainlevel-nav"><li><a href="/joomla/about-joomla" class="mainlevel-nav" >About Joomla!</a></li><li><a href="/joomla/features" class="mainlevel-nav" >Features</a></li><li><a href="/joomla/news" class="mainlevel-nav" >News</a></li><li><a href="/joomla/the-community" class="mainlevel-nav" >The Community</a></li></ul>					</div>

				</div>
			</div>
		</div>
###### End of odd output (this comment wasn't in the code) #####

        </div>
     <div class="TitleLinkedMenu">

###### etc. Other jammed XHTMLlinkedMenu menus come here  (this comment wasn't in the code) #####

      </div>

###### Then, the commented output  (this comment wasn't in the code) #####
	
		      <!-- 		<div class="module">
			<div>
				<div>
					<div>
													<h3>Livres et musique (Boutique)</h3>
											<ul id="mainlevel-nav"><li><a href="/joomla/about-joomla" class="mainlevel-nav" >About Joomla!</a></li><li><a href="/joomla/features" class="mainlevel-nav" >Features</a></li><li><a href="/joomla/news" class="mainlevel-nav" >News</a></li><li><a href="/joomla/the-community" class="mainlevel-nav" >The Community</a></li></ul>					</div>
				</div>
			</div>
		</div>
			<div class="module">

###### etc. Other rounded menus come here  (this comment wasn't in the code) #####

		</div>
	 -->
</div>			

###### End of the leftcolumn  (this comment wasn't in the code) #####

I didn't try more tests neither looked at the J! core to understand this bug. Ask the core team if you want.

User avatar
dorjano
Joomla! Explorer
Joomla! Explorer
Posts: 432
Joined: Tue Aug 30, 2005 11:26 am
Location: Slovenia
Contact:

Re: Link module title

Post by dorjano » Sat Jun 07, 2008 3:29 pm

Wohoho! Indeed! You're right, it's unbelievable! I didn't even thought about to check this, then I use Firefox's Web Dev ant there it is. Nice discovery though Ollvin! you should report this bug to the Joomla! team since you discover it. Good job, good job!!! Please DO report this bug!!

Regards,
Dorjano
Moderator of Slovenian Forum

User avatar
daebat
Joomla! Explorer
Joomla! Explorer
Posts: 372
Joined: Tue Jun 05, 2007 7:33 pm
Location: Atlanta, Ga

Re: Link module title

Post by daebat » Tue Feb 03, 2009 5:38 pm

how can I do this to something other than a menu?
-Daebat
Dictated But Not Read

User avatar
sbinnie
Joomla! Apprentice
Joomla! Apprentice
Posts: 8
Joined: Wed May 16, 2007 11:17 am
Location: Richmond Hill, Ontario, Canada
Contact:

Re: Link module title

Post by sbinnie » Thu Aug 20, 2009 6:16 pm

daebat wrote:how can I do this to something other than a menu?
I have just written a blog about using Ollvin's concept to create linked titles in Jumi modules. The same can be applied to most Joomla! 1.5 module types.

http://www.scottbinnie.com/j15/blog/Lin ... dules.html

Simmon
Joomla! Apprentice
Joomla! Apprentice
Posts: 19
Joined: Tue Jun 23, 2009 1:43 am

Re: Link module title

Post by Simmon » Fri Aug 21, 2009 11:19 pm

If you don't want to make changes to the core file - there are two commercial extensions we offer that can do the trick - Advanced Contexts Manager(full control over modules) and Content Enhancer(enhancing Joomla content in various ways).
Enless Soft Ltd.
Web Development Department
Website: http://enless-soft.com/products

fabricebaro
Joomla! Apprentice
Joomla! Apprentice
Posts: 13
Joined: Wed Nov 18, 2009 10:45 pm

Re: Link module title

Post by fabricebaro » Tue Mar 02, 2010 3:21 pm

The title of modules is not displayed if "Title link URL" not set.
I added the "else :" and "echo..." lines to the modChrome_XHTMLlinkedMenu function in module.php. Works neatly.

Code: Select all

else : // FAB: added because title wasn't displayed if "Title Link URL" is not set.
echo "<h".$headerLevel.">".$module->title."</h".$headerLevel.">";
Novices: just replace the whole previously added function in modules.php by this one:

Code: Select all

 function modChrome_XHTMLlinkedMenu($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.">";
                else : // FAB: added because title wasn't displayed if "Title Link URL" is not set.
                        echo "<h".$headerLevel.">".$module->title."</h".$headerLevel.">";
                endif;
            endif;
            echo $module->content;
            ?>
        </div>
    <?php endif;
}
?>

Aly
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 235
Joined: Mon Aug 22, 2005 8:56 pm

Re: Link module title

Post by Aly » Thu Mar 24, 2011 7:21 pm

Just discovered a MUCH simpler method to enable links for Module Title bars!!
I just downloaded and installed Sourcerer from nonumber.nl

http://www.nonumber.nl/extensions/sourcerer

In my module title field (from module manager) added this in place of Title Text:
{source}[[a href="http://www.google.com"]]MODULE TITLE NAME[[/a]]{/source}

Then added appropriate css to template.css so the links would display properly.
Presto! Amazing! EASY!!

Not affiliated with NoNumber! but I am a huge fan!!

zhizunbao84
Joomla! Apprentice
Joomla! Apprentice
Posts: 17
Joined: Wed Apr 13, 2011 9:02 am

Re: Link module title

Post by zhizunbao84 » Wed May 04, 2011 8:56 am

i use yoo_explorer Template, there is no "<jdoc:include type="modules" name="X" style="Y"/>" tags in my index.php template file.

the index.php code below:
<?php
/**
* @package yoo_explorer Template
* @file index.php
* @version 5.5.7 November 2010
* @author YOOtheme http://www.yootheme.com
* @copyright Copyright (C) 2007 - 2010 YOOtheme GmbH
* @license YOOtheme Proprietary Use License (http://www.yootheme.com/license)
*/

// no direct access
defined('_JEXEC') or die('Restricted access');

// include config
include_once(dirname(__FILE__).'/config.php');

// load main template file, located in /layouts/template.php
echo $warp->template->render('template');

User avatar
RustyJoomla
Joomla! Explorer
Joomla! Explorer
Posts: 395
Joined: Wed Aug 01, 2007 12:08 am
Location: UK
Contact:

Re: Link module title

Post by RustyJoomla » Mon May 16, 2011 10:39 am

How would this work when using the WARP framework as "jdoc include" isn't used in the templates index.php file
Follow me on Twitter - http://twitter.com/RustyJoomla
Company Joomla Website - https://storm.agency

jfbeaulieu
Joomla! Apprentice
Joomla! Apprentice
Posts: 5
Joined: Sun Jun 26, 2011 8:14 pm

Re: Link module title

Post by jfbeaulieu » Sun Jun 26, 2011 8:22 pm

Hi,

I would like to do the same thing as you but instead of a link, I would like to be able to chose an article (like we chose an article when we set a sub-menu to show a simple article). Where I can find the code to able to do that ?

Thank you very much !
Jeff

User avatar
sbinnie
Joomla! Apprentice
Joomla! Apprentice
Posts: 8
Joined: Wed May 16, 2007 11:17 am
Location: Richmond Hill, Ontario, Canada
Contact:

Re: Link module title

Post by sbinnie » Tue Jun 28, 2011 10:05 am

zhizunbao84 wrote:i use yoo_explorer Template, there is no "<jdoc:include type="modules" name="X" style="Y"/>" tags in my index.php template file.

the index.php code below:
<?php
/**
* @package yoo_explorer Template
* @file index.php
* @version 5.5.7 November 2010
* @author YOOtheme http://www.yootheme.com
* @copyright Copyright (C) 2007 - 2010 YOOtheme GmbH
* @license YOOtheme Proprietary Use License (http://www.yootheme.com/license)
*/

// no direct access
defined('_JEXEC') or die('Restricted access');

// include config
include_once(dirname(__FILE__).'/config.php');

// load main template file, located in /layouts/template.php
echo $warp->template->render('template');
Check the last section and then try the " /layouts/template.php" file.

User avatar
sbinnie
Joomla! Apprentice
Joomla! Apprentice
Posts: 8
Joined: Wed May 16, 2007 11:17 am
Location: Richmond Hill, Ontario, Canada
Contact:

Re: Link module title

Post by sbinnie » Tue Jun 28, 2011 10:07 am

stormit wrote:How would this work when using the WARP framework as "jdoc include" isn't used in the templates index.php file
Warp is a Yoo product... there should be a " /layouts/template.php" file to check (see last post)

User avatar
sbinnie
Joomla! Apprentice
Joomla! Apprentice
Posts: 8
Joined: Wed May 16, 2007 11:17 am
Location: Richmond Hill, Ontario, Canada
Contact:

Re: Link module title

Post by sbinnie » Tue Jun 28, 2011 10:13 am

jfbeaulieu wrote:Hi,

I would like to do the same thing as you but instead of a link, I would like to be able to chose an article (like we chose an article when we set a sub-menu to show a simple article). Where I can find the code to able to do that ?

Thank you very much !
Jeff
A quick answer would be that since you are linking to the article, you simply use an article link. However, I think that what you are asking for is a modal link mechanism to select an article from a list of them.

In that case, I suppose it would be possible to put together some kind of kludgy module type to handle it, but I think you would best be served by creating some sort of plugin that has the structure to handle a wider scope of user inputs.

jusy777
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Sun Sep 11, 2011 10:07 am

Re: Link module title

Post by jusy777 » Sun Sep 11, 2011 10:09 am

Does anyone have instructions on how to make this hack with joomla 1.7?

velhecz
Joomla! Apprentice
Joomla! Apprentice
Posts: 7
Joined: Fri Dec 02, 2005 10:28 pm
Location: Poland

Re: Link module title

Post by velhecz » Thu Nov 24, 2011 7:49 pm

[quote="Aly"]Just discovered a MUCH simpler method to enable links for Module Title bars!!
I just downloaded and installed Sourcerer from nonumber.nl

http://www.nonumber.nl/extensions/sourcerer
...
[/quote]

Simple, brilliant and it works:) Thanks.

toomy
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Tue Nov 29, 2011 5:49 pm

Re: Link module title

Post by toomy » Tue Nov 29, 2011 8:59 pm

ollvin wrote:Ok. Let's be more "specific". (That's for J!1.5, I don't know if this was part of previous versions) Don't pay attention to approximativ labels, that's my own translation (my Joomla! language is French).
Open the file your_joomla_folder/modules/mod_mainmenu/mod_mainmenu.xml where are stored all parameters fields you can find in the right column, in a menu module properties page in Joomla admin (Extensions/Module manager/Your menu).
You can add a <PARAM ...> line anywhere you want with a new name (variable name in the database) and an intelligible label (like "the stuff I did some day", hum...) (each <PARAMS></PARAMS> section is a conterner group of parameters in the admin, like Module parameters, Advanced parmeters...). I choosed to put my own parameter at the end of the first contener because it's displayed first when you open your module page (Be lazy :D). Like this :

Code: Select all

	<params>
		<param name="menutype" type="mos_menu" default="" label="Menu Name" description="The name of the menu (default is mainmenu)" />
		<param name="menu_style" type="list" default="list" label="Menu Style" description="The menu style">
			<option value="list">List</option>
			<option value="vert_indent">Legacy - Vertical</option>
			<option value="horiz_flat">Legacy - Horizontal</option>
			<option value="list_flat">Legacy - Flat List</option>
		</param>
		<param name="@spacer" type="spacer" default="" label="" description="" />
		<param name="startLevel" type="text" default="0" size="5" label="Start Level" description="PARAMSTARTLEVEL" />
		<param name="endLevel" type="text" default="0" size="5" label="End Level" description="PARAMSTOPLEVEL" />
		<param name="showAllChildren" type="radio" default="0" label="Always show submenu items" description="PARAMSHOWSUBMENUITEMS">
			<option value="0">No</option>
			<option value="1">Yes</option>
		</param>
		<param name="@spacer" type="spacer" default="" label="" description="" />
		<param name="window_open" type="text" default="" label="Target Position" description="PARAMTARGETPOSITION" />

<!-- HERE IS A BRAND NEW PARAM -->

	    <param name="titleLink" type="text" default="" label="Title link URL" description="PARAMLINKURL" />

<!-- END OF THE BRAND NEW PARAM -->
	

</params>
Save and upload your file and go to a menu module properties in the Module manager : tada! there's a nice field "Title link URL" on the right. Put any URL coming out of your mind in it and save.

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 can see a line like this one :

Code: Select all

titleLink=hihihi.com
(That's Walt Disney's secret postmortem blog... Chht! Don't tell anyone)
Magic ! Your URL is now stored in the database.

So. Let's come back to our J! trick.
Open templates/system/html/modules.php : you can see one function () for each style option available when you insert a <jdoc:include type="modules" name="X" style="Y"/> tag in your index.php template file.
You could modify the XHTML one but it's not really good if you what to keep that normal option for any other purpose than your "title linked" menu.
Let's add a new option.
First we're going to put it in our own my_template folder to be more flexible later, (and J! standard compliant, of course...). Create a html/ folder in your template folder and copy the modules.php file there : templates/my_template/html/modules.php
Open this new copy and delete all function () blocks (they can't be set twice - in system folder and in your_template folder - this causes an error) or keep just the XHTML one to modify it. Give the function an other name. You can add all your esoteric html around <?php ?> place holders and - finally - add the magic place holder <?php echo $params->get('titleLink'); ?> to output your URL in some < a href=""> attribute. Like this :

Code: Select all

function modChrome_XHTMLlinkedMenu($module, &$params, &$attribs)
{
	if (!empty ($module->content)) : ?>
	   <div class="TitleLinkedMenu">	
                        <?php if ($module->showtitle != 0) : ?>		
	            <h3><a href="<?php echo $params->get('titleLink'); ?>"><?php echo $module->title; ?></a></h3>
                        <?php endif; ?>
                        <div class="TitleLinkedMenuContent">
                           <?php echo $module->content; ?>
                        </div>
                    </div>

	<?php endif;
}
Save and upload your file.

Then, don't forget to call your menu with the good jdoc tag style in your index.php template file : <jdoc:include type="modules" name="X" style="XHTMLlinkedMenu"/>

Well, uff... :geek: Enough details ?
I there a commentary on the wonderful and hard I could take advantage of it Thank you

tuto
Joomla! Fledgling
Joomla! Fledgling
Posts: 3
Joined: Tue Nov 29, 2011 6:03 pm

Re: Link module title

Post by tuto » Tue Nov 29, 2011 9:20 pm

ollvin wrote:Well... I made a test with your code and I think I fixed your problem : simply remove the commented old code. That's a pure J! bug ! :D
It seems J! doesn't see comments and output code when it find a <Jdoc:> tag, even commented. This shouldn't matter : J! output normal code but, as it's commented, browsers don't display it.
But this double occurence strangely makes J! go mad : it also output the the whole second (commented) occurence of the <Jdoc:> in the content part of the first.
Don't ask why...
If you look at the outputed source code in your browser (that's what I meant asking the source code) you see something like this :

Code: Select all

  <div id="leftcolumn">
     <div class="TitleLinkedMenu">
		      				
		     <h3><a href="http://www.editions-theia.com">Livres et musique (Boutique)</a></3
		        <div class="TitleLinkedMenuContent">

###### Outputing whole rounded version in this content part (this comment wasn't in the code) #####

        		<div class="module">
			<div>
				<div>
					<div>
													<h3>Livres et musique (Boutique)</h3>
											<ul id="mainlevel-nav"><li><a href="/joomla/about-joomla" class="mainlevel-nav" >About Joomla!</a></li><li><a href="/joomla/features" class="mainlevel-nav" >Features</a></li><li><a href="/joomla/news" class="mainlevel-nav" >News</a></li><li><a href="/joomla/the-community" class="mainlevel-nav" >The Community</a></li></ul>					</div>

				</div>
			</div>
		</div>
###### End of odd output (this comment wasn't in the code) #####

        </div>
     <div class="TitleLinkedMenu">

###### etc. Other jammed XHTMLlinkedMenu menus come here  (this comment wasn't in the code) #####

      </div>

###### Then, the commented output  (this comment wasn't in the code) #####
	
		      <!-- 		<div class="module">
			<div>
				<div>
					<div>
													<h3>Livres et musique (Boutique)</h3>
											<ul id="mainlevel-nav"><li><a href="/joomla/about-joomla" class="mainlevel-nav" >About Joomla!</a></li><li><a href="/joomla/features" class="mainlevel-nav" >Features</a></li><li><a href="/joomla/news" class="mainlevel-nav" >News</a></li><li><a href="/joomla/the-community" class="mainlevel-nav" >The Community</a></li></ul>					</div>
				</div>
			</div>
		</div>
			<div class="module">

###### etc. Other rounded menus come here  (this comment wasn't in the code) #####

		</div>
	 -->
</div>			

###### End of the leftcolumn  (this comment wasn't in the code) #####

I didn't try more tests neither looked at the J! core to understand this bug. Ask the core team if you want.

Very cool thank you


Locked

Return to “Extensions for Joomla! 1.5”