Home » Forum
NoNumber!

Joomla! extensions & websites
development / support / consultancy

I try to respond within 24 hours (excluding weekends). If I haven't responded by then, feel free to post a reminder or bug me via email.
Welcome, Guest
Please Login or Register.    Lost Password?

mod_custom category name
(1 viewing) (1) Guest
Go to bottomPage: 1
TOPIC: mod_custom category name
#9954
mod_custom category name 1 Month, 3 Weeks ago  
Greetings from Australia,

Thank you for your work, I am using Sourcerer.
I am hoping someone can help me.


I have 12 categories published as blogs linked via menu buttons.
I want to make 1 header template file using php that will print the category name.

I tried to use mod_custom add place it on each of the menu items, but I can not seem to retrieve the category name.

I have used this code:

{source}<?php global $Catid; ?>
<?php echo $category->title; ?>{/source}


Any suggetions?

Again thank you
Rick
Rick Conn
Posts: 4
User OfflineClick here to see the profile of this user
The administrator has disabled public write access.
 
#9959
Re: mod_custom category name 1 Month, 3 Weeks ago  
The category name is not stored in the global variables. Also the $catid may not be present as global.
So you'll have to grab the catid from the url and do a database search for the title. try:
{source}<?php
$view = JRequest::getCmd( 'view' );
$id = JRequest::getInt( 'id' );
if ( $view == 'category' && $id ) {
$query = "
SELECT title FROM #__categories
WHERE id = ".(int) $id."
LIMIT 1;
";
$database->setQuery( $query );
$category = $database->loadResult();
echo '<h1>'.$category.'</h1>';
}
?>{/source}
Peter van Westen
Admin
Posts: 4533
User OfflineClick here to see the profile of this user
The administrator has disabled public write access.
Need to contact me directly? Go to my contact page.
If you use any NoNumber! extensions, please post a rating and a review at the Joomla! Extensions Directory.
Are you happy with the support? Please consider buying a License Code to help me to continue development and support.
 
#9963
Re: mod_custom category name SOLVED 1 Month, 3 Weeks ago  
Hello,

Thank you for the quick reply...

You sir are the master, and I am but a grasshopper.
I'm sorry for the small donation, I would give more if I could.

I only hope you receive enough for your good work.

Thank you Peter.
Rick Conn
Posts: 4
User OfflineClick here to see the profile of this user
The administrator has disabled public write access.
 
#9964
Re: mod_custom category name SOLVED 1 Month, 3 Weeks ago  
No problem Rick
Thanks you very much for the donation!
Peter van Westen
Admin
Posts: 4533
User OfflineClick here to see the profile of this user
The administrator has disabled public write access.
Need to contact me directly? Go to my contact page.
If you use any NoNumber! extensions, please post a rating and a review at the Joomla! Extensions Directory.
Are you happy with the support? Please consider buying a License Code to help me to continue development and support.
 
Go to topPage: 1
Joomla Open Source Training