Actions

Difference between revisions of "Using a custom image in the menu bar title"

From Joomla! Documentation

m (Needs addition of the alternate and easier way to do this (since joomla 1.5?))
m (fake-template trouble removed)
Line 1: Line 1:
To use a custom image in the Menu Bar title we need an image (obviously) and a little bit of CSS.
 
 
{{ambox
 
{{ambox
 
| image = jdoc
 
| image = jdoc
Line 11: Line 10:
 
</includeonly>
 
</includeonly>
 
<!--Last line of your template code-->
 
<!--Last line of your template code-->
<noinclude>
 
{{documentation}}
 
<!-- Add categories and interwikis to the /doc subpage, not here! -->
 
</noinclude>
 
 
  
 +
To use a custom image in the Menu Bar title we need an image (obviously) and a little bit of CSS.
  
 
First off, create the following folders in your administrator component (we're using a fictitious component called com_notes as the example).  Then place your image in the ''images'' folder and create a new file called ''default.css'' in the css folder, like this:
 
First off, create the following folders in your administrator component (we're using a fictitious component called com_notes as the example).  Then place your image in the ''images'' folder and create a new file called ''default.css'' in the css folder, like this:

Revision as of 13:07, 14 August 2012

To use a custom image in the Menu Bar title we need an image (obviously) and a little bit of CSS.

First off, create the following folders in your administrator component (we're using a fictitious component called com_notes as the example). Then place your image in the images folder and create a new file called default.css in the css folder, like this:

com_notes
|- assets
..|- css
....|- default.css
..|- images
....|- logo.png

The code for the CSS file looks like this:

/* Toolbar */
.icon-48-notes {
    background: url(../images/logo.png) no-repeat left;
}

Next we tell the menubar handler function to use this css by the following invocation of the title method of JMenuBar:

JMenuBar::title( JText::_( 'Notes List' ), 'notes' );

Notice that value of the second argument, notes, marries with the suffix of the CSS class.

Finally we need to load the component custom CSS file. Place the following code typically near the top of admin.notes.php:

$document =& JFactory::getDocument();
$document->addStyleSheet( '/components/com_notes/assets/css/default.css' );

You can, of course, use default.css for more than just the title styling.