Custom Title Tag Hack for every page

Your code modifications and patches you want to share with others.
User avatar
barnett
Joomla! Intern
Joomla! Intern
Posts: 76
Joined: Fri Aug 19, 2005 12:52 pm
Location: Nyack, NY

Re: Custom Title Tag Hack for every page

Post by barnett » Wed May 03, 2006 12:45 pm

@ limin - to my knowledge sections can only appear if you link to them from a menu, so you can set the custom title in the menu params.

@ mattr2110 - categories are a different question.  If they are linked to directly in the menu then the same applies from above, otherwise I'm not sure how to do it since there are no params for categories.  :(

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

User avatar
leslienord
Joomla! Apprentice
Joomla! Apprentice
Posts: 24
Joined: Fri Mar 17, 2006 7:47 pm
Contact:

Re: Custom Title Tag Hack for every page

Post by leslienord » Mon May 08, 2006 1:04 pm

Can this be used after implementing the Joomla SEF Patch? I found that patch before I found this.

User avatar
slimtreeshadow
Joomla! Apprentice
Joomla! Apprentice
Posts: 23
Joined: Thu May 11, 2006 7:32 pm
Contact:

This works great

Post by slimtreeshadow » Tue May 16, 2006 8:53 pm

A great addition - thanks so much!

-adam
Adam Audette, Moderator & Publisher

LED Digest | Marketing Discussion List
http://www.led-digest.com/
since 1997

Lionel
Joomla! Intern
Joomla! Intern
Posts: 87
Joined: Tue Oct 04, 2005 2:12 am

Re: Custom Title Tag Hack for every page

Post by Lionel » Mon Jul 10, 2006 1:13 am

First thank you for that solution.
It appears that linked menus to static content are unaffected by that hack. Can someone confirm please?
Last edited by Lionel on Mon Jul 10, 2006 1:17 am, edited 1 time in total.

jkrobin
Joomla! Apprentice
Joomla! Apprentice
Posts: 33
Joined: Mon Aug 29, 2005 3:10 pm

Re: Custom Title Tag Hack for every page

Post by jkrobin » Thu Jul 27, 2006 2:01 pm

With the default includes/joomla.php, how would I go about just reversing the SiteName-PageTitle order? (This is with dynamic page titles turned on and working at present (http://www.shadowmonkey.net).

The result I'm looking for is to have PageTitle-SiteName show up insteaded of SiteName-PageTitle.

Thanks for any help.

jkrobin

User avatar
barnett
Joomla! Intern
Joomla! Intern
Posts: 76
Joined: Fri Aug 19, 2005 12:52 pm
Location: Nyack, NY

Re: Custom Title Tag Hack for every page

Post by barnett » Thu Jul 27, 2006 2:43 pm

jkrobin wrote: With the default includes/joomla.php, how would I go about just reversing the SiteName-PageTitle order?
For the default includes/joomla.php look in the setPageTitle() function and replace this line:

Code: Select all

$this->_head['title'] = $title ? $GLOBALS['mosConfig_sitename'] . ' - '. $title : $GLOBALS['mosConfig_sitename'];
with this line:

Code: Select all

$this->_head['title'] = $title ? $title . ' - '. $GLOBALS['mosConfig_sitename'] : $GLOBALS['mosConfig_sitename'];

if you are using the Custom Title Tag hack I created above and want to switch the order look in the same function and replace:

Code: Select all

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

Code: Select all

$title = $custom_title ? $custom_title : $title . ' - '. $GLOBALS['mosConfig_sitename'];
or if you want the Site Name to follow your Custom Title Tag then switch the same line with:

Code: Select all

$title = $custom_title ? $custom_title . ' - '. $GLOBALS['mosConfig_sitename'] : $title . ' - '. $GLOBALS['mosConfig_sitename'];
Enjoy.
-barnett
http://www.contemplatedesign.com/ - Joomla Development & Design

jkrobin
Joomla! Apprentice
Joomla! Apprentice
Posts: 33
Joined: Mon Aug 29, 2005 3:10 pm

Re: Custom Title Tag Hack for every page

Post by jkrobin » Thu Jul 27, 2006 3:37 pm

Thanks very much, barnett! ...works great.

-jkrobin

krishtaurus
Joomla! Fledgling
Joomla! Fledgling
Posts: 1
Joined: Sat Jul 29, 2006 11:52 am

Re: Custom Title Tag Hack for every page

Post by krishtaurus » Mon Jul 31, 2006 10:25 am

Hello Barnett,

Thanks for such wonderful procedure for custom title tag. After using this hack we are able to place custom tag on each page, but we are still not able to edit the Meta Tags on the index page. Can you help me in placing custom Meta Tags on the index page. One more issue which I need to discuss is, after using the hack I find Two Title Tags been generated on my page, as shown below

This is your custom title


Is there any option to omit from the page...

Thanks!

spacebass5000
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 110
Joined: Sun Nov 20, 2005 7:00 pm

Re: Custom Title Tag Hack for every page

Post by spacebass5000 » Tue Aug 01, 2006 11:29 pm

Lionel wrote: First thank you for that solution.
It appears that linked menus to static content are unaffected by that hack. Can someone confirm please?
It looks to me that any menu type "Link - *" inherits the custom title of what it is actually linking to. I tried linking the Home link in my main menu to my top menu and the custom title I set for my top menu link did not get displayed.
Because Joomla ROCKS!!! It f*@cking ROCKS I say!!!

Scarpantibus
Joomla! Apprentice
Joomla! Apprentice
Posts: 8
Joined: Wed Dec 21, 2005 11:14 am

Re: Custom Title Tag Hack for every page - problems with apostrophes

Post by Scarpantibus » Sun Sep 10, 2006 8:50 pm

Hi, I have a problem - that I partially solved - with apostrophe in page titles.

If the custom title contains an apostrophe a slash is been added before it.
So, if title_cust parameter is
Bob's page

the page title will be rendered as
Bob\''s page

My solution consists in changing the joomla.php hack in the following way (modificaitions in bold red):

function setPageTitle( $title=null, $params=null ) {
if (@$GLOBALS['mosConfig_pagetitles']) {
if ($params) {
$custom_title = stripslashes($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 = stripslashes($params->def( 'title_cust', '' ));
}
$title = $custom_title ? $custom_title : $GLOBALS['mosConfig_sitename'] . ' - '. $title;
$title = stripslashes( $title );
$title = trim( htmlspecialchars( $title ) );
$this->_head['title'] = $title ? $title : $GLOBALS['mosConfig_sitename'];
}
}


Not very complex, as you can see...a simple stripslashes command.
This solves the problem on the frontend: the page title has no more slashes.

But doesn't solve the problem in the backend. Infact, clicking on a content Item to edit it, the 'Custom Title' parameter filed contains the slashes. Saving the content without correcting it means that next time i click on that content i will find one more slash...and so on.

I repeat: this doesn't affect my frontpage, the user won't see any slash. But I think that my solution in not very elegant...
Does anyone have a better idea?

Thank you,
Scarpantibus

shawn122
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 183
Joined: Fri Mar 03, 2006 10:47 pm
Location: Toronto

Re: Custom Title Tag Hack for every page

Post by shawn122 » Sun Sep 10, 2006 8:56 pm

general comment:  its a good hack but becomes pointless when Joomla issues so many release versions that forces you to re edit the files in question.  When you maintain a large numbers of Joomla sites, it becomes a real pain in the but.  I cant see why this can't be implemented into the core instead of it being a "hack"

I like the Joomla SEF patch and that should also get taken into consideration.

spacebass5000
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 110
Joined: Sun Nov 20, 2005 7:00 pm

Re: Custom Title Tag Hack for every page

Post by spacebass5000 » Mon Sep 11, 2006 12:21 pm

I agree. It would be nice to see this included in the core files. This is a HUGE issue for any site wanting to tweak their meta-tags for SEO purposes.
Because Joomla ROCKS!!! It f*@cking ROCKS I say!!!

JSalvador
Joomla! Intern
Joomla! Intern
Posts: 80
Joined: Sat Nov 26, 2005 2:59 am

Re: Custom Title Tag Hack for every page

Post by JSalvador » Wed Sep 13, 2006 4:52 pm

Just wanted to say thanks. This really helped me

caribk
Joomla! Apprentice
Joomla! Apprentice
Posts: 5
Joined: Thu Oct 06, 2005 6:07 pm

Re: Custom Title Tag Hack for every page

Post by caribk » Wed Sep 27, 2006 3:59 pm

great hack by the way..

just noticed while implementing this for SEO purposes that in components/com_content/content.php (J! 1.0.10) there are calls to SetPageTitle instead of setPageTitle, and the only implementation of a page title function i can find is the setPageTitle in includes/joomla.php.

is this a type-o, or am i missing something?

User avatar
josey
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 100
Joined: Thu Jan 12, 2006 9:10 pm
Location: Lake Michigan

Re: Custom Title Tag Hack for every page

Post by josey » Fri Sep 29, 2006 3:56 pm

great hack. thanks.

it seemed to work on the site i used it on, but the second site i did it shows the title tag field on the content pages, but only shows up on the site's title area if the page is a static page?

joomla 1.0.11

any ideas
cheers
############

fixed it. i triple checked the .xml files, moved the parm to the top, and edited the title tag field in the content pull down list, instead of going to the mainmenu list of pages, where i also have a title tag fields.

cheers
Last edited by josey on Fri Sep 29, 2006 5:19 pm, edited 1 time in total.

User avatar
php4ever
Joomla! Explorer
Joomla! Explorer
Posts: 290
Joined: Tue Aug 30, 2005 3:40 pm
Location: United States of America
Contact:

JOOMLA 1.0.11 Custom Title Tags

Post by php4ever » Mon Oct 16, 2006 1:18 pm

Here is a zip file I created with all the changes and backups in place. 

Its intended for use by new installs of Joomla 1.0.11, however if you have third party components you will just need to go to those components and add the following line as originally instructed.



I will maintain successive packages to help out with barnett if thats ok, as each release of Joomla becomes available so in the event that Joomla releases 1.0.12 and so on I'll make it as an easy drop in.

Just follow the instructions in the README.TXT file included with the zip. http://www.jaredsdesigns.com/downloads/ ... 1.0.11.zip

~ Jared
POST KEYWORDS: "Joomla 1.0.11 Custom Title, Titles Tags, Dynamic Titles"
PS Good Job "barnett"
Last edited by php4ever on Wed Nov 01, 2006 6:13 pm, edited 1 time in total.
Smart people bridge with Joomla, not integrate
http://www.jaredritchey.com

triggeru571
Joomla! Apprentice
Joomla! Apprentice
Posts: 28
Joined: Sun May 28, 2006 7:46 am

OPENSEF now not working

Post by triggeru571 » Thu Oct 26, 2006 7:03 pm

This is a great hack, thanks. Been looking around for some time. But now my opensef refuses to work for any new URL's. If fine for anything which exists, I just cant get it to re-write new ones. Any idea?

triggeru571
Joomla! Apprentice
Joomla! Apprentice
Posts: 28
Joined: Sun May 28, 2006 7:46 am

Re: OPENSEF now not working

Post by triggeru571 » Thu Oct 26, 2006 7:08 pm

triggeru571 wrote: This is a great hack, thanks. Been looking around for some time. But now my opensef refuses to work for any new URL's. If fine for anything which exists, I just cant get it to re-write new ones. Any idea?


:-[ opps - sorry guys - False Alarm. My mistake! I must have turned off theEnable SEF URL's from the main config. Its now working perfectly.

:-[:-[:-[:-[:-[:-[

User avatar
LeGaS
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 111
Joined: Thu Aug 18, 2005 9:07 am
Location: Hungary

Re: Custom Title Tag Hack for every page

Post by LeGaS » Tue Nov 07, 2006 4:24 pm

This is a really nice hack, but I've got a problem with it. :(
When I edit the components/com_content/content.php file and upload it, then all of my content items disappear. They are in the database and in the administration, but I can't see them on the frontpage / menu items.

Do you have any idea?

User avatar
php4ever
Joomla! Explorer
Joomla! Explorer
Posts: 290
Joined: Tue Aug 30, 2005 3:40 pm
Location: United States of America
Contact:

Re: Custom Title Tag Hack for every page

Post by php4ever » Tue Nov 07, 2006 5:26 pm

this happens when you edit that file in more than one place.

Download the examples I have above in the zip file and try the content.php file in there and see if that helps.



Jared
Smart people bridge with Joomla, not integrate
http://www.jaredritchey.com

User avatar
LeGaS
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 111
Joined: Thu Aug 18, 2005 9:07 am
Location: Hungary

Re: Custom Title Tag Hack for every page

Post by LeGaS » Tue Nov 07, 2006 5:47 pm

Great, thanks! :) It solved the problem.

Regards,
LeGaS

User avatar
slimtreeshadow
Joomla! Apprentice
Joomla! Apprentice
Posts: 23
Joined: Thu May 11, 2006 7:32 pm
Contact:

How about upgrades

Post by slimtreeshadow » Fri Nov 10, 2006 9:49 pm

Anyone try this w/ upgrade installations? I've upgraded to 1.011 from about 1.07 or so. Before I risk it I wanted to check if anyone else tried already.
Adam Audette, Moderator & Publisher

LED Digest | Marketing Discussion List
http://www.led-digest.com/
since 1997

patjk
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 105
Joined: Sun Jul 16, 2006 7:29 pm

Re: Custom Title Tag Hack for every page

Post by patjk » Sat Nov 11, 2006 2:54 am

Works nicely, thanks.

User avatar
eyezberg
Joomla! Hero
Joomla! Hero
Posts: 2860
Joined: Thu Aug 25, 2005 5:48 pm
Location: Geneva mostly
Contact:

Re: Custom Title Tag Hack for every page

Post by eyezberg » Sat Nov 11, 2006 9:01 pm

Using SEF Advance, Joomla 1.0.11, SEF Patch.
Applied all 4 steps, double checked all changes.
Only thing that works is for content items, the content title is now used.
Any custom title inserted on menu links is simply ignored?!
Help welcome.
Sometimes one pays most for the things one gets for nothing.
The important thing is not to stop questioning. Curiosity has its own reason for existing. AE
http://joomla15.[URL banned].com for J! 1.5 screenshots
http://www.eyezberg.com

User avatar
infinitimm
Joomla! Intern
Joomla! Intern
Posts: 66
Joined: Mon Jul 24, 2006 5:14 pm
Location: Ireland
Contact:

Re: Custom Title Tag Hack for every page

Post by infinitimm » Mon Nov 13, 2006 10:09 am

Thanks Barnett,

A well considered and elegant solution to this problem, you have done us all a great service. Works brilliantly for me and will really help my optimisation.

Very good instructions, I am just a lowly web designer and not a programmer, but could follow the instructions to the letter.
:: mean business ::
http://www.infinitimixedmedia.com
[If this helps, please pay it forward]

User avatar
eyezberg
Joomla! Hero
Joomla! Hero
Posts: 2860
Joined: Thu Aug 25, 2005 5:48 pm
Location: Geneva mostly
Contact:

Re: Custom Title Tag Hack for every page

Post by eyezberg » Mon Nov 13, 2006 9:27 pm

Does this work for you guys WITH SEF Advance (or another 3rd party sef solution) enabled?
I checked all edits again, it should be ok but works only on content items!? Not links to categoruies, sections or any other components I edited the xml for..
Sometimes one pays most for the things one gets for nothing.
The important thing is not to stop questioning. Curiosity has its own reason for existing. AE
http://joomla15.[URL banned].com for J! 1.5 screenshots
http://www.eyezberg.com

User avatar
barnett
Joomla! Intern
Joomla! Intern
Posts: 76
Joined: Fri Aug 19, 2005 12:52 pm
Location: Nyack, NY

Re: Custom Title Tag Hack for every page

Post by barnett » Tue Nov 14, 2006 1:38 pm

eyezberg wrote: Using SEF Advance, Joomla 1.0.11, SEF Patch.
Applied all 4 steps, double checked all changes.
Only thing that works is for content items, the content title is now used.
Any custom title inserted on menu links is simply ignored?!
Help welcome.
I have not tested it with the SEF ADvance or SEF Patch.... but I do use OpenSEF and it doesn't seem to interfere.

Has anyone else had this issue with SEF Patch?

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

User avatar
slimtreeshadow
Joomla! Apprentice
Joomla! Apprentice
Posts: 23
Joined: Thu May 11, 2006 7:32 pm
Contact:

Re: Custom Title Tag Hack for every page

Post by slimtreeshadow » Tue Nov 14, 2006 5:44 pm

With JRE's SEF patch extended this doesn't work - at least it doesn't work for 1.010. I haven't tried w/ 1.011 yet.

It seems to interefere somehow w/ the custom title tags on menu items. It's just as eyezberg says.
Adam Audette, Moderator & Publisher

LED Digest | Marketing Discussion List
http://www.led-digest.com/
since 1997

User avatar
eyezberg
Joomla! Hero
Joomla! Hero
Posts: 2860
Joined: Thu Aug 25, 2005 5:48 pm
Location: Geneva mostly
Contact:

Re: Custom Title Tag Hack for every page

Post by eyezberg » Tue Nov 14, 2006 9:13 pm

sllim' thanks for confirming, (even tho' i use the free patch), I thought I was becoming stupid..
Sometimes one pays most for the things one gets for nothing.
The important thing is not to stop questioning. Curiosity has its own reason for existing. AE
http://joomla15.[URL banned].com for J! 1.5 screenshots
http://www.eyezberg.com

User avatar
slimtreeshadow
Joomla! Apprentice
Joomla! Apprentice
Posts: 23
Joined: Thu May 11, 2006 7:32 pm
Contact:

Re: Custom Title Tag Hack for every page

Post by slimtreeshadow » Tue Nov 14, 2006 10:41 pm

You bet. Here's a related thread about custom title tags w/ the JoomlatWork patch - http://www.joomlatwork.com/forum/index.php?topic=41.0.
Adam Audette, Moderator & Publisher

LED Digest | Marketing Discussion List
http://www.led-digest.com/
since 1997


Locked

Return to “Core Hacks and Patches”