The Joomla! Forum ™





Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 103 posts ]  Go to page 1, 2, 3, 4  Next
Author Message
PostPosted: Wed Feb 08, 2006 7:51 pm 
User avatar
Joomla! Intern
Joomla! Intern

Joined: Fri Aug 19, 2005 12:52 pm
Posts: 76
Location: Nyack, NY
Many have talked about needing the ability to create custom title tags for every page.

http://forum.joomla.org/index.php/topic,11357.0.html
http://forum.joomla.org/index.php/topic,18041.0.html

This hack will accomplish allowing you to set custom Title Tags for every menu item and content item in the parameter fields.  This will help with SEO of your Joomla site unitl these issues are hopefully implemented in Joomla 1.1.

Here are the steps:
Please backup your files first

1. Insert Custom Title Tag Parameters

add the following line of code as a childNode of the node
Code:
<param name="title_cust" type="text" size="20" default="" label="Custom Title Tag" description="A custom Title tag to be applied to the page, this allows individual page titling" />

in the following .xml files:


administrator/components/com_menus/component_item_link/component_item_link.xml
and every subfolder under the com_menus/ directory that contains a .xml file. (ex. content_section/content_section.xml)

administrator/components/com_banners/banners.xml
and every subfolder under the administrator/components/ directory that contains a .xml installer file. (ex. com_frontpage/frontpage.xml)
Note: when you install a new component you will have to add the line of code to the component's .xml installer file


2. Edit content.php File

open file: components/com_content/content.php

look under the function showItem and replace the following code around line 1341:
Code:
// page title
$mainframe->setPageTitle( $row->title );


with this:
Code:
// page title
$mainframe->setPageTitle( $row->title, $params );



3. Edit joomla.php File

open file: includes/joomla.php (for Mambo: includes/mambo.php)

look for function setPageTitle under the class mosMainFrame around line 468 and replace:  (Mambo line: 128)
Code:
function setPageTitle( $title=null ) {
       if (@$GLOBALS['mosConfig_pagetitles']) {
          $title = trim( htmlspecialchars( $title ) );
         $this->_head['title'] = $title ? $GLOBALS['mosConfig_sitename'] . ' - '. $title : $GLOBALS['mosConfig_sitename'];
      }
   }


with this:
Code:
   function setPageTitle( $title=null, $params=null ) {
      if (@$GLOBALS['mosConfig_pagetitles']) {
         if ($params) {
            $custom_title = $params->def( 'title_cust', '' );
         } else {
            global $database, $mainframe, $Itemid;
            $params = new stdClass();
            if ( $Itemid ) {
               $menu = new mosMenu( $database );
               $menu->load( $Itemid );
               $params = new mosParameters( $menu->params );
            } else {
               $menu = "";
               $params = new mosParameters( '' );   
            }
            $custom_title = $params->def( 'title_cust', '' );
         }
         $title = $custom_title ? $custom_title : $GLOBALS['mosConfig_sitename'] . ' - '. $title;
         $title = trim( htmlspecialchars( $title ) );
         $this->_head['title'] = $title ? $title : $GLOBALS['mosConfig_sitename'];
      }
   }



4. Edit the root index.php File  *new addition

open file: index.php  (not your template one, but the actual one in your root folder of your Joomla install)

after line 100 where you see this:
Code:
// mainframe is an API workhorse, lots of 'core' interaction routines
$mainframe = new mosMainFrame( $database, $option, '.' );
$mainframe->initSession();


insert this below that code:
Code:
$mainframe->setPageTitle();


this addition makes up for the fact that some third party components don't call the setPageTitle function.  this way it is always called.

That should complete the hack!

Now log into the administrator end and change the "Custom Title Tag" parameters on your menu items and content items.  If you leave the parameter blank then Joomla will use the default Site Name and page Name as the Title.

Let me know if this works or doesn't.  Have fun.

-Barnett

_________________
http://www.contemplatedesign.com/ - Joomla Development & Design


Last edited by barnett on Tue Apr 25, 2006 5:28 pm, edited 1 time in total.

Top
 Profile  
 
PostPosted: Thu Feb 09, 2006 8:53 am 
Joomla! Intern
Joomla! Intern

Joined: Tue Oct 04, 2005 7:58 am
Posts: 76
great one for SEO . thx

_________________
http://www.mopays.com.


Top
 Profile  
 
PostPosted: Thu Feb 09, 2006 12:49 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Mon Jan 16, 2006 2:18 pm
Posts: 29
Great post, thanks. If people want to always have the site name in the title tag as well as the custom title then this code results in "$customtitle - $sitetitle" style title tags.

Instead of:
Code:
$title = $custom_title ? $custom_title : $GLOBALS['mosConfig_sitename'] . ' - '. $title;


Put:
Code:
$title = $custom_title ? $custom_title  . ' - ' . $GLOBALS['mosConfig_sitename'] : $GLOBALS['mosConfig_sitename'] . ' - '. $title;


Top
 Profile  
 
PostPosted: Sun Feb 26, 2006 9:13 pm 
Joomla! Intern
Joomla! Intern

Joined: Thu Nov 10, 2005 4:32 pm
Posts: 54
Absolutely brilliant, now i need to get to work with my keywords and page titles  ;D

One thing - how do i make the content item name show before the site name?

I did already have a hack for it but can't find it.


Top
 Profile  
 
PostPosted: Fri Mar 03, 2006 9:54 am 
Joomla! Apprentice
Joomla! Apprentice

Joined: Mon Dec 26, 2005 12:07 pm
Posts: 9
This is an excellent mod. No, this isn't a hack! :)

Really, I'm falling over myself how happy I am. Worked like a charm. Thank you so much!!!

Geoffrey


Top
 Profile  
 
PostPosted: Wed Mar 08, 2006 1:56 pm 
Joomla! Intern
Joomla! Intern

Joined: Thu Nov 10, 2005 4:32 pm
Posts: 54
Dehaw wrote:
Absolutely brilliant, now i need to get to work with my keywords and page titles  ;D

One thing - how do i make the content item name show before the site name?

I did already have a hack for it but can't find it.


I changed this line:

Code:
$title = $custom_title ? $custom_title  . ' - ' . $GLOBALS['mosConfig_sitename'] : $GLOBALS['mosConfig_sitename'] . ' - '. $title;


to

Code:
$title = $custom_title ? $custom_title  . ' : ' . $GLOBALS['mosConfig_sitename'] : $title .' : '. $GLOBALS['mosConfig_sitename'];


Now it shows the content name before the site name if there is no custom tag  ;D


Top
 Profile  
 
PostPosted: Mon Apr 03, 2006 6:29 pm 
Joomla! Fledgling
Joomla! Fledgling

Joined: Mon Apr 03, 2006 6:23 pm
Posts: 3
I have incorporated your code upon your instruction but I don't seem to get the required result. The page title continues to work as it did: "Site name - Dynamic Page name" which makes me think that the parameters are not passed in correctly into the clause.
Any ideas anyone?
Chris


Top
 Profile  
 
PostPosted: Mon Apr 03, 2006 9:11 pm 
User avatar
Joomla! Intern
Joomla! Intern

Joined: Fri Aug 19, 2005 12:52 pm
Posts: 76
Location: Nyack, NY
cmdelivor wrote:
I have incorporated your code upon your instruction but I don't seem to get the required result. The page title continues to work as it did: "Site name - Dynamic Page name" which makes me think that the parameters are not passed in correctly into the clause.
Any ideas anyone?
Chris


Do you have an example to look at?  Maybe also a screen capture of what it looks like for the administrator as well?  Tell us more about what version of Joomla you are using.  Have you modified your code before?

-barnett

_________________
http://www.contemplatedesign.com/ - Joomla Development & Design


Top
 Profile  
 
PostPosted: Tue Apr 04, 2006 2:59 pm 
Joomla! Fledgling
Joomla! Fledgling

Joined: Mon Apr 03, 2006 6:23 pm
Posts: 3
The domain is http://www.fuelture.com. It's currently running Mambo 4.5.3 and we're in the process of migrating to Joomla. I have some experience with core hacking before, so I'm pretty sure what I did was correct according to the instructions. and it seems to produce the right title for the webpage as if there were no parameters. I'm thinking that for some reason the clause for the parameters is not executed. But I can't tell, if that's the case, why the $params are not passed on correctly. The code lloks ok but it doesn't work for me.
Any pointers would be appreciated.
Chris.


Top
 Profile  
 
PostPosted: Tue Apr 04, 2006 7:21 pm 
User avatar
Joomla! Intern
Joomla! Intern

Joined: Fri Aug 19, 2005 12:52 pm
Posts: 76
Location: Nyack, NY
Are you running OpenSEF?  That may be the problem.

-barnett

_________________
http://www.contemplatedesign.com/ - Joomla Development & Design


Top
 Profile  
 
PostPosted: Tue Apr 04, 2006 8:02 pm 
User avatar
Joomla! Champion
Joomla! Champion

Joined: Thu Aug 18, 2005 2:09 am
Posts: 5373
Location: California
barnett wrote:
Are you running OpenSEF?  That may be the problem.

-barnett


1. OpenSEF does not run on Mambo 4.5.3

2. OpenSEF is not going to affect the code executed within that PHP file.

3. I have done various Title hacks with no problems.

_________________
██ AllMedia4Joomla Project
██ http://sourceforge.net/projects/allmedia4joomla/
██ AllMedia YöuTube Feed Gallery module released
██ Download: http://sourceforge.net/projects/allmedia4joomla/files/


Top
 Profile  
 
PostPosted: Tue Apr 04, 2006 8:11 pm 
User avatar
Joomla! Intern
Joomla! Intern

Joined: Fri Aug 19, 2005 12:52 pm
Posts: 76
Location: Nyack, NY
@ kenmcd:  I like openSEF ;D but I just hadn't tested with this hack.  Thanks for clearing that up.

@ cmdelivor:  I've never tested this with Mambo 4.5.3, only 4.5.2 and all Joomla versions

-barnett

_________________
http://www.contemplatedesign.com/ - Joomla Development & Design


Top
 Profile  
 
PostPosted: Wed Apr 05, 2006 1:17 am 
Joomla! Fledgling
Joomla! Fledgling

Joined: Mon Apr 03, 2006 6:23 pm
Posts: 3
I see. Thanks for your help guys. I think I will wait till we migrate to Joomla.
Cheers.


Top
 Profile  
 
PostPosted: Wed Apr 05, 2006 1:59 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Wed Dec 21, 2005 11:14 am
Posts: 8
Thank you very much for this hack!

I've tested it on Joomla 1.0.8 and the last release of OpenSEF and everything is ok.

Hope it will be implemented in next Joomla 1.5 release.

Thanks again,
Scarpantibus


Top
 Profile  
 
PostPosted: Wed Apr 05, 2006 2:16 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Sun Nov 20, 2005 6:53 pm
Posts: 15
barnett wrote:

Now log into the administrator end and change the "Custom Title Tag" parameters on your menu items and content items.  If you leave the parameter blank then Joomla will use the default Site Name and page Name as the Title.



I can't find this parameter :o Where should it be?
Thanks
Andrea


Top
 Profile  
 
PostPosted: Wed Apr 05, 2006 3:04 pm 
User avatar
Joomla! Intern
Joomla! Intern

Joined: Fri Aug 19, 2005 12:52 pm
Posts: 76
Location: Nyack, NY
barnett wrote:
1. Insert Custom Title Tag Parameters

add the following line of code as a childNode of the node
Code:
<param name="title_cust" type="text" size="20" default="" label="Custom Title Tag" description="A custom Title tag to be applied to the page, this allows individual page titling" />

in the following .xml files:


administrator/components/com_menus/component_item_link/component_item_link.xml
and every subfolder under the com_menus/ directory that contains a .xml file. (ex. content_section/content_section.xml)

administrator/components/com_banners/banners.xml
and every subfolder under the administrator/components/ directory that contains a .xml installer file. (ex. com_frontpage/frontpage.xml)
Note: when you install a new component you will have to add the line of code to the component's .xml installer file


Did you follow this step correctly and add the param tag above within the code here tag in each .xml file for the menus and components?

It should appear then under the paramaters tab in content items as well as on the right in the parameters area when creating a menu item.

-barnett

_________________
http://www.contemplatedesign.com/ - Joomla Development & Design


Top
 Profile  
 
PostPosted: Wed Apr 05, 2006 3:20 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Sun Nov 20, 2005 6:53 pm
Posts: 15
barnett wrote:
Did you follow this step correctly and add the param tag above within the code here tag in each .xml file for the menus and components?


I think yes. I post here: http://www.alientech.it/title.rar modified xml files. Can you check them?
Thanks!
Andrea


Top
 Profile  
 
PostPosted: Wed Apr 05, 2006 4:02 pm 
User avatar
Joomla! Intern
Joomla! Intern

Joined: Fri Aug 19, 2005 12:52 pm
Posts: 76
Location: Nyack, NY
Most of the files look correct.  I did notice on some where you were adding this as the first param that you didn't put it between the tag.  For example on banners.xml you have:

Code:
<param name="title_cust" type="text" size="20" default="" label="Custom Title Tag" description="A custom Title tag to be applied to the page, this allows individual page titling" />
  <params />


but it should be this:
Code:
<params>
<param name="title_cust" type="text" size="20" default="" label="Custom Title Tag" description="A custom Title tag to be applied to the page, this allows individual page titling" />
 </params>


Anyway take a look at one of your menu items (ex: a link to static content item) and you should see the parameter to your right when you edit the item.  I've attached a screenshot.

-barnett


You do not have the required permissions to view the files attached to this post.

_________________
http://www.contemplatedesign.com/ - Joomla Development & Design


Top
 Profile  
 
PostPosted: Wed Apr 05, 2006 4:04 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Sun Nov 20, 2005 6:53 pm
Posts: 15
I solved the problem.
Hint: don't open the files with dreamweaver 4.0: it alter code structure!
Thanks!
Andrea


Last edited by muppy on Wed Apr 05, 2006 4:06 pm, edited 1 time in total.

Top
 Profile  
 
PostPosted: Wed Apr 05, 2006 11:14 pm 
Joomla! Explorer
Joomla! Explorer

Joined: Thu Feb 16, 2006 2:42 am
Posts: 273
Once I did the custom title tag hack this no longer worked

http://forum.joomla.org/index.php/topic ... #msg176875

Does this work for anyone?


Top
 Profile  
 
PostPosted: Tue Apr 11, 2006 3:44 pm 
User avatar
Joomla! Explorer
Joomla! Explorer

Joined: Mon Sep 05, 2005 11:21 am
Posts: 338
Location: Nis, Serbia
Will this be implenetned in 1.5???

_________________
http://www.pcigre.com -> game community


Top
 Profile  
 
PostPosted: Fri Apr 21, 2006 4:34 pm 
User avatar
Joomla! Intern
Joomla! Intern

Joined: Tue Nov 01, 2005 9:39 pm
Posts: 96
Location: Mulhouse
does not go with mambo 4.5.2 Fr
the title are to record in menu but not enabled in frontend... ???

_________________
http://www.alsasys.com - Web Agency spécialisée dans les solutions libres pour les entreprises:

[X] Développement spécifique (Joomla / Oscommerce/ Magento)
[X] Conseil et formation
[X] Web design
[X] Référencement / e-marketing


Top
 Profile  
 
PostPosted: Fri Apr 21, 2006 5:02 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Fri Mar 24, 2006 4:03 am
Posts: 31
Thanks so much for the hack.  I have it installed and it works pretty good, but it doesn't seem to work on all things.  I have a few menu items that the page title is not being rewritten from the default of sitename.

For example, I have a menu item defined that displays an item from the xtratings component which uses facileforms.  I edited the menu item to include a custom title but the custom title does not appear.  I have several other menu items behaving in the same manner. 

I am pretty much clueless to much of this, but I don't understand what the point of modifying all the XML files in the components subfolders was for.  Many of the components don't have a parameters page.  So there is no way to enter a custom title.


Top
 Profile  
 
PostPosted: Mon Apr 24, 2006 3:58 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Mon Apr 24, 2006 3:32 pm
Posts: 5
10x for the hack.

It works great on menu items but I can't find the "Custom Title Tag" parameter when I edit a content item. I have checked and I think I did everything ok. I am using Joomla 1.08. Can someone help me?


Top
 Profile  
 
PostPosted: Tue Apr 25, 2006 2:31 pm 
User avatar
Joomla! Intern
Joomla! Intern

Joined: Fri Aug 19, 2005 12:52 pm
Posts: 76
Location: Nyack, NY
@ Adr |an

  In step one of the hack did you include the paramater line in the following files:
  administrator/components/com_content/content.xml
  administrator/components/com_typedcontent/typedcontent.xml

  After you insert it there it should appear under the "parameters" tab of each content item and static content items.


@ limin
 
    What menu item type did you use?  I've noticed Link-URL will not work with this hack, I think.  But if there is a specific menu type for xtdratings then you should add the param line from step one into the com_menus .xml file for xtdratings.  What type are the other menu items you've noticed not working?

  You're right about the components.  Not all xml files need to be edited.  Only the ones that appear on the frontend like com_contacts, com_content, com_frontpage, com_typedcontent, etc...

-barnett

_________________
http://www.contemplatedesign.com/ - Joomla Development & Design


Top
 Profile  
 
PostPosted: Tue Apr 25, 2006 4:08 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Fri Mar 24, 2006 4:03 am
Posts: 31
The menu type that is not working is Component.  I have several defined in my top navigation and none of them work.  Each has a paramenter field that allows for the insertion of the custom title, but the custom title isn't getting rewritten to the page title.

I have double checked the com_menu/Components/components.xml for the proper entry.  This is what I have:

Quote:

   
   



Which I think is correct.


Top
 Profile  
 
PostPosted: Tue Apr 25, 2006 5:25 pm 
User avatar
Joomla! Intern
Joomla! Intern

Joined: Fri Aug 19, 2005 12:52 pm
Posts: 76
Location: Nyack, NY
limin wrote:
The menu type that is not working is Component.  I have several defined in my top navigation and none of them work.  Each has a paramenter field that allows for the insertion of the custom title, but the custom title isn't getting rewritten to the page title.


Fixed it.  The reason it works for some components and not others is the fact that some don't call the setPageTitle function.  I've added a step #4 to this hack which will fix this issue.  See original post.

-barnett

_________________
http://www.contemplatedesign.com/ - Joomla Development & Design


Top
 Profile  
 
PostPosted: Tue Apr 25, 2006 8:19 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Fri Mar 24, 2006 4:03 am
Posts: 31
Barnet;

Thanks very much for the update.  Step four seems to have solved the problem.


Top
 Profile  
 
PostPosted: Tue May 02, 2006 3:46 pm 
Joomla! Explorer
Joomla! Explorer

Joined: Thu Feb 16, 2006 2:42 am
Posts: 273
Is there a way to apply this to categories? Inside the admin there is no parameters" tab for categories.


Top
 Profile  
 
PostPosted: Tue May 02, 2006 3:48 pm 
Joomla! Apprentice
Joomla! Apprentice

Joined: Fri Mar 24, 2006 4:03 am
Posts: 31
That would be very nice.  Sections too!


Top
 Profile  
 
Display posts from previous:  Sort by  
Forum locked This topic is locked, you cannot edit posts or make further replies.  [ 103 posts ]  Go to page 1, 2, 3, 4  Next



Who is online

Users browsing this forum: No registered users and 1 guest


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:  
cron
Powered by phpBB® Forum Software © phpBB Group