Customize joomla menu title and position with CSS

Morgan
Morgan used Ask the Experts™
on
I am wanting to know if there is a way to place the title of a joomla menu in a specific place.
I know I can use:

<?php echo $this->title; ?>

to show the title of an article and place it anywhere on the page to show it.

Is there a similar way for titles of menus?

Essentially, I am wanting to place the menu title between the <h4></h4> tags that are defined within the CSS file.

Thanks,

neonate
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Allan NisbetOwner at Storm IT Solutions LTD

Commented:
You could have a look at the menu plugin for joomla and take the code for menu name out of the php file.

Storm
Allan NisbetOwner at Storm IT Solutions LTD

Commented:
Maybe this code will help

<?php
  if ($module->showtitle)
  {
    echo '<h2>' .$module->title .'</h2>';
  }
?>

Author

Commented:
Storm:

The posted code did not work :(. What menu plugin for joomla do you speak of?
Owner at Storm IT Solutions LTD
Commented:
Did you put the above code into the module for the menu?

If you used it outwith the module then it wont work as it wont know which $module its meant to be calling the title of.

http://docs.joomla.org/Tutorial:More_on_Joomla!_modules

This is from the joomla documentation info (like wiki)

This site should have what you need

Storm

Author

Commented:
Storm:

Sorry for getting back late. busy busy busy.

Anyway...

I've gone to the link you provided--Thanks!--and I have made changes but I'm still not able to get the title to show.  I'm thinking that my code is just not right.

Code below:
<div id="menu1-top">
                			<?php if ($this->countModules( 'user2' )) :  ?>
  								<?php echo '<h4>' .$module->title .'</h4>';	?>
							<?php endif; ?>
                    </div>
                    <div id="menu1-content">
                    	<div class="menu-content">
                    		<jdoc:include type="modules" name="user2" />      
                        </div>
                    </div>
                    <div id="menu1-bottom">
                    </div>

Open in new window

Author

Commented:
Storm:

Alright after some more playing around I got it :)

I appreciate your help!

The working code is below.
<div id="menu1-top">
<h4>
<?php if ($this->countModules( 'user2' )) :  ?>
<?php $module->title;	?>
<?php endif; ?>
</h4>
</div>
<div id="menu1-content">
<div class="menu-content">
<jdoc:include type="modules" name="user2" style="xhtml" />      
</div>
</div>
<div id="menu1-bottom">
</div>

Open in new window

Author

Commented:
Thank you!

Author

Commented:
I would like correct the earlier code. The code I posted above actully did not work at--I made an error in what I beleived to be correct, but unfortently was not.

To render the title of a menu as I wanted i need to go a bit further: the is acutally found here:

http://woofandwarp.com/blog/2-joomla/19-having-fun-with-joomla-module-chrome-and-suffix

The code I used within the modules.php file (explained in the above link) was this (the following code is my own custom code to corrospond with my CSS styling:

function modChrome_modheader($module, &$params, &$attribs)
{
echo '<h4>'.JText::_( $module->title). '</h4>';
echo '<div class="moduletable">'.$module->content.'</div>';
}
?>

I then had to go to the index.php file and change the style attribut within module call to this:

<jdoc:include type="modules" name="user1" style="modheader" />

I had to make a few minor changes within my css to position my my title where I wanted, but now I have officially corrected the code.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial