Joomla! Discussion Forums



It is currently Wed Nov 25, 2009 2:35 pm (All times are UTC )

 


Forum rules

Please submit all new Tips and Tricks to: http://docs.joomla.org/Category:Tips_and_tricks

This forum section will be closed and removed eventually.



Post new topic Reply to topic  [ 2 posts ] 
Author Message
Posted: Tue Jul 22, 2008 1:12 am 
Joomla! Apprentice
Joomla! Apprentice
Offline

Joined: Wed May 23, 2007 7:37 pm
Posts: 29
Hello,
Sometimes we would like to have a submenu item point to a new article as soon as the article is written, and this without having to edit the menu (see post Adding Articles Automatically to Menu)

This can be done in Joomla 1.5 via the latestnews module and an HTML override:

1. Create a latestnews module to list all the articles in the category which we want to add to the menu.
The module's output can be formatted per stylesheet in exactly the same manner as a 'real' submenu. (Use module style="xhtml" to get a simple <ul> lists.)

2. Under 'Menu Assignment' configure this latestnews module to only display when the appropriate main menu item is active.
This pseudo-submenu will then show up when the specific main menu item has been selected and it will disappear as soon as another main menu item is selected. Other main menu items may of course still contain real submenu item.

Now we have a 'pseudo submenu' which looks and behaves like a real submenu . The only disadvantage is the lack of the "active" attribute which prevents us from visually marking the currently selected submenu item.

To get this work as well, install an HTML override in the template:
3. In the active template's folder create the subfolder structure 'html/mod_latestnews' (unless your template already has this override)
4. In this folder 'html/mod_latestnews'...
a) create a file 'index.html'. (Just copy one from any other folder).
b) create a file 'default.php'. This is the code which will overrride the standard 'latestnews' output.

The content of 'default.php' is:
Code:
<?php // @version $Id: default.php 9718 2007-12-20 22:35:36Z eddieajau $
defined('_JEXEC') or die('Restricted access');
//rjo 2008.07.15, rewrite to identify which article is active.
if (count($list)){
$uri = JFactory::getURI()->toString();
echo '<ul class="latestnews'.$params->get('pageclass_sfx').'">';
foreach ($list as $item){
  if(strpos($uri, $item->link) === false)
   $act = '';
  else
   $act = ' active';
  echo '<li class="latestnews'.$params->get('pageclass_sfx').$act.'">';
  echo ' <a href="'.$item->link.'">'.$item->text.'</a></li>';
  }
  echo '</ul>';
}
?>


This checks if the link target is the same as the current page. If yes, it adds the 'active' class attribute.
I guess this could be enhanced (shorter, add other output style options, prevent the not very likely case that the test gives a wrong positive result, etc.).
Hope that helps


Top
  E-mail  
 
Posted: Tue Jul 22, 2008 1:14 am 
User avatar
Joomla! Master
Joomla! Master
Offline

Joined: Fri Aug 12, 2005 12:38 am
Posts: 11201
Location: Sydney - Australia
Brilliant..

Get this in here: http://docs.joomla.org/Category:Tips_and_tricks people need to see this.

BTW did you see this: http://theartofjoomla.com/magazine/arti ... nique.html

_________________
Brad Baker - Follow me on Twitter @xyzulu @rochenhost
http://www.rochen.com - Joomla! Hosting, the correct way.
http://www.joomlatutorials.com <-- Joomla Help
..somewhere in this hospital the anguished oink of a pig man cries out for help..


Top
  E-mail  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 2 posts ] 

Quick reply

 



Who is online

Users browsing this forum: No registered users and 9 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group