Display article title as page title in browser

Need help with the Administration of your Joomla! 2.5 site? This is the spot for you.

Moderator: General Support Moderators

Forum rules
Forum Rules
Absolute Beginner's Guide to Joomla! <-- please read before posting, this means YOU.
Forum Post Assistant - If you are serious about wanting help, you will use this tool to help you post.
andrewj1313
Joomla! Apprentice
Joomla! Apprentice
Posts: 10
Joined: Tue Aug 17, 2010 1:50 pm

Display article title as page title in browser

Post by andrewj1313 » Tue Oct 04, 2011 1:35 pm

In Joomla 1.5, if I did not specify a page title within the menu item, Joomla would automatically use the article title as the page title. In Joomla 1.7, this is not the case, Joomla simply uses the menu item title as the page title. How can I over-ride this without having to retype the article title in the menu page display options, browser page title dialog?

tstem
Joomla! Apprentice
Joomla! Apprentice
Posts: 5
Joined: Thu Oct 06, 2011 2:25 pm

Re: Display article title as page title in browser

Post by tstem » Tue Oct 25, 2011 1:15 am

I'm having the same problem of course. Anyone know how to fix this? thx!

User avatar
Webdongle
Joomla! Master
Joomla! Master
Posts: 36761
Joined: Sat Apr 05, 2008 9:58 pm

Re: Display article title as page title in browser

Post by Webdongle » Tue Oct 25, 2011 1:50 am

Menu item edit screen Metadata Options
http://www.weblinksonline.co.uk/
https://www.weblinksonline.co.uk/updating-joomla.html
"The definition of insanity is doing the same thing over and over again, but expecting different results": Albert Einstein
Member of the CMS Release Team

tstem
Joomla! Apprentice
Joomla! Apprentice
Posts: 5
Joined: Thu Oct 06, 2011 2:25 pm

Re: Display article title as page title in browser

Post by tstem » Tue Oct 25, 2011 1:55 am

I have no problem displaying titles of articles under the menu items, its the articles I am using as internal links that are not showing the titles in the browser bar.

User avatar
Webdongle
Joomla! Master
Joomla! Master
Posts: 36761
Joined: Sat Apr 05, 2008 9:58 pm

Re: Display article title as page title in browser

Post by Webdongle » Tue Oct 25, 2011 1:58 am

Use this Technique http://docs.joomla.org/How_to_control_m ... _menu_item to control the Metadata Options of those Articles. Use http://extensions.joomla.org/extensions ... editors/88 to make the internal link to the Hidden menu from an Article.
http://www.weblinksonline.co.uk/
https://www.weblinksonline.co.uk/updating-joomla.html
"The definition of insanity is doing the same thing over and over again, but expecting different results": Albert Einstein
Member of the CMS Release Team

tstem
Joomla! Apprentice
Joomla! Apprentice
Posts: 5
Joined: Thu Oct 06, 2011 2:25 pm

Re: Display article title as page title in browser

Post by tstem » Tue Oct 25, 2011 2:08 am

ok thanks. I was hoping I could avoid doing this as it is not needed with my 1.5 sites.

User avatar
Webdongle
Joomla! Master
Joomla! Master
Posts: 36761
Joined: Sat Apr 05, 2008 9:58 pm

Re: Display article title as page title in browser

Post by Webdongle » Tue Oct 25, 2011 2:25 am

If it's not needed then why bother doing it ?
http://www.weblinksonline.co.uk/
https://www.weblinksonline.co.uk/updating-joomla.html
"The definition of insanity is doing the same thing over and over again, but expecting different results": Albert Einstein
Member of the CMS Release Team

tstem
Joomla! Apprentice
Joomla! Apprentice
Posts: 5
Joined: Thu Oct 06, 2011 2:25 pm

Re: Display article title as page title in browser

Post by tstem » Tue Oct 25, 2011 2:32 am

in 1.5 its not needed to put the articles under a hidden menu so that the page names are displayed in the browser....it is done automatically, or at least it was when I set-up the 1.5 sites.

User avatar
Webdongle
Joomla! Master
Joomla! Master
Posts: 36761
Joined: Sat Apr 05, 2008 9:58 pm

Re: Display article title as page title in browser

Post by Webdongle » Tue Oct 25, 2011 2:48 am

tstem wrote:in 1.5 its not needed to put the articles under a hidden menu so that the page names are displayed in the browser....
It puts the the menu item as the Browser page Title unless it is overridden by the Menu item Meta Options.
tstem wrote:I have no problem displaying titles of articles under the menu items, its the articles I am using as internal links that are not showing the titles in the browser bar.
So you need to give it a menu item so it has a Browser title.

If you want to control the Browser Title for a page then AFAIK it needs to be done through the Menu item. If you know of another way that would be useful.
http://www.weblinksonline.co.uk/
https://www.weblinksonline.co.uk/updating-joomla.html
"The definition of insanity is doing the same thing over and over again, but expecting different results": Albert Einstein
Member of the CMS Release Team

User avatar
DeanMarshall
Joomla! Hero
Joomla! Hero
Posts: 2352
Joined: Fri Aug 19, 2005 2:26 am
Location: Lancaster, Lancashire, United Kingdom
Contact:

Re: Display article title as page title in browser

Post by DeanMarshall » Fri Nov 04, 2011 2:11 pm

I've got to jump in here because this is just wrong - unless I'm missing something really obvious this is broken.

The <title> tag when viewing an article should contain the article's title, surely.
Having an 'option' to override this with some other text is fine and is how it has been since way way back.

BUT, defaulting to using short text from a menu item instead of the article text is crazy - surely this is wrong. It would be nonsense to create a hidden menu link for every article in a site. And it seems a lot of extra effort to have to manually set the title for every page that is a single article - why duplicate effort re-entering a title we already entered when creating the article.

Dean
Dean Marshall Consultancy - six Joomla experts - http://www.deanmarshall.co.uk/

Joomla Experts - Joomla Support http://www.deanmarshall.co.uk/joomla-se ... pport.html

andrewj1313
Joomla! Apprentice
Joomla! Apprentice
Posts: 10
Joined: Tue Aug 17, 2010 1:50 pm

Re: Display article title as page title in browser

Post by andrewj1313 » Fri Nov 04, 2011 2:20 pm

I completely agree, Dean. 1.5.x did it, I don't know why 1.6 and 1.7 won't :-\

User avatar
DeanMarshall
Joomla! Hero
Joomla! Hero
Posts: 2352
Joined: Fri Aug 19, 2005 2:26 am
Location: Lancaster, Lancashire, United Kingdom
Contact:

Re: Display article title as page title in browser

Post by DeanMarshall » Fri Nov 04, 2011 11:21 pm

I've got a blog post underway - probably post it tomorrow but I have a workaround for anyone interested.

basically you need to create a template override - and add two lines of code within the file. Here is a summary:

If you are following along and need to implement this fix yourself please start by checking whether you have a this file in the following location:
/templates/your-template/html/com_content/article/default.php

If you already have such a file, great that's what we are going to edit. If you do not have a file with that name, in that location don't worry - we just need to navigate to
/components/com_content/views/article/tmpl/default.php

Copy that file to your local machine, and then upload it to
/templates/your-template/html/com_content/article/default.php

Fortunately the template we are using for that particular client site already has a template override in place, so things were fairly easy.

Somewhere towards the top of the file you'll find a line which outputs the article's title as a heading - in h1 or h2 tags. Look for this snippet.

Code: Select all

$this->item->title
Somewhere just after it - within php tags add the following code:

Code: Select all

	$document=& JFactory::getDocument();
	$document->setTitle( $this->item->title );
Let me know how you get on and I'll update the thread tomorrow with a link to the blog post which will cover a little more ground.
Dean Marshall Consultancy - six Joomla experts - http://www.deanmarshall.co.uk/

Joomla Experts - Joomla Support http://www.deanmarshall.co.uk/joomla-se ... pport.html

User avatar
Webdongle
Joomla! Master
Joomla! Master
Posts: 36761
Joined: Sat Apr 05, 2008 9:58 pm

Re: Display article title as page title in browser

Post by Webdongle » Fri Nov 04, 2011 11:34 pm

I like that is there a way of getting the Articles Title Alias ?
http://www.weblinksonline.co.uk/
https://www.weblinksonline.co.uk/updating-joomla.html
"The definition of insanity is doing the same thing over and over again, but expecting different results": Albert Einstein
Member of the CMS Release Team

User avatar
DeanMarshall
Joomla! Hero
Joomla! Hero
Posts: 2352
Joined: Fri Aug 19, 2005 2:26 am
Location: Lancaster, Lancashire, United Kingdom
Contact:

Re: Display article title as page title in browser

Post by DeanMarshall » Fri Nov 04, 2011 11:46 pm

You should be able to access any property of the current article via variables in the form of:
$this->item->title
$this->item->alias
$this->item->title_alias
$this->item->(any other property name).

To get a full list of properties available try this within the default.php file - but not on a live site as it kills the site:

Code: Select all

die(print_r($this->item), true);
Dean
Dean Marshall Consultancy - six Joomla experts - http://www.deanmarshall.co.uk/

Joomla Experts - Joomla Support http://www.deanmarshall.co.uk/joomla-se ... pport.html

User avatar
Webdongle
Joomla! Master
Joomla! Master
Posts: 36761
Joined: Sat Apr 05, 2008 9:58 pm

Re: Display article title as page title in browser

Post by Webdongle » Sat Nov 05, 2011 1:13 am

I have just tested on a fresh install of Joomla using a standard Template no Article Override.

In the menu edit screen for
Extensions >>> Components >>> Content Component >> Article Category list
index.php/using-joomla/extensions/components/content-component/article-category-list
I set the Browser page Title to 'Browser page'

I changed the Beginners Article to 'Beginners Title'
and the Title Alias to 'beginners-title-alias'
(This has no menu item)

The menu item Browser page Title displayed in the Browser from that menu item
The Article Title displayed in the Browser when following the link on the page.
The Article Title Alias displayed in the url
So it works from the menu item without creating/editing a Template override.

It would appear that your first test was polluted with the Template override ? Could test with /templates/your-template/html/com_content/article/ renamed to see what happens please ?
Screenshot-866.png
Screenshot-867.png
You do not have the required permissions to view the files attached to this post.
http://www.weblinksonline.co.uk/
https://www.weblinksonline.co.uk/updating-joomla.html
"The definition of insanity is doing the same thing over and over again, but expecting different results": Albert Einstein
Member of the CMS Release Team

User avatar
DeanMarshall
Joomla! Hero
Joomla! Hero
Posts: 2352
Joined: Fri Aug 19, 2005 2:26 am
Location: Lancaster, Lancashire, United Kingdom
Contact:

Re: Display article title as page title in browser

Post by DeanMarshall » Sat Nov 05, 2011 1:28 am

Webdongle,

With all due respect i think you have missed th point of this thread all the way through.

We are talking about creating a menu link to a SINGLE article.
And we are talking about the <title> tag - in the source code - not the <h1> heading in the page.

Please create an article with title: 'Article with very very long title'.
Create a menu item of type 'single article' with the title (second box down on left) of 'short title'.
In the site view your article by clicking the menu link 'short title'.
The page will show you the heading <h1> or <h2> in the page 'Article with very very long title'.
Now view the source of the page - and look at the <title> tag.
If your <title> doesn't contain 'Article with very very long title' it is WRONG.

If that isn't clear please wait for my blog post tomorrow - which walk through the issue in more detail complete with images that show things more clearly.

Dean
Dean Marshall Consultancy - six Joomla experts - http://www.deanmarshall.co.uk/

Joomla Experts - Joomla Support http://www.deanmarshall.co.uk/joomla-se ... pport.html

User avatar
DeanMarshall
Joomla! Hero
Joomla! Hero
Posts: 2352
Joined: Fri Aug 19, 2005 2:26 am
Location: Lancaster, Lancashire, United Kingdom
Contact:

Re: Display article title as page title in browser

Post by DeanMarshall » Sat Nov 05, 2011 1:31 am

Does anyone think it some kind of coincidence that ALL of Joomla's demo content consists of articles with titles of 2 or three short words?
Dean Marshall Consultancy - six Joomla experts - http://www.deanmarshall.co.uk/

Joomla Experts - Joomla Support http://www.deanmarshall.co.uk/joomla-se ... pport.html

User avatar
Webdongle
Joomla! Master
Joomla! Master
Posts: 36761
Joined: Sat Apr 05, 2008 9:58 pm

Re: Display article title as page title in browser

Post by Webdongle » Sat Nov 05, 2011 1:54 am

DeanMarshall wrote:Webdongle,

With all due respect i think you have missed th point of this thread all the way through.

We are talking about creating a menu link to a SINGLE article.
And we are talking about the <title> tag - in the source code - not the <h1> heading in the page.
....
Screenshot-871.png
Screenshot-870.png
1.
If an Article has no menu item then:
The Article Title is Displayed in the source code <title> tag in the <head> code. This then displays at the top of the Browser.

2.
If an Article has a menu item directly to it then if the 'Browser page Title' is given a value. Then that then displays at the top of the Browser. If the menu item does not have a value for the 'Browser page Title' then the menu item Title is used.
You do not have the required permissions to view the files attached to this post.
http://www.weblinksonline.co.uk/
https://www.weblinksonline.co.uk/updating-joomla.html
"The definition of insanity is doing the same thing over and over again, but expecting different results": Albert Einstein
Member of the CMS Release Team

User avatar
DeanMarshall
Joomla! Hero
Joomla! Hero
Posts: 2352
Joined: Fri Aug 19, 2005 2:26 am
Location: Lancaster, Lancashire, United Kingdom
Contact:

Re: Display article title as page title in browser

Post by DeanMarshall » Sat Nov 05, 2011 2:16 am

We don't want to have to override the menu item's short title by re-typing in the full article title int the menu item's "Page Display Options" -> "Browser page title" - we are leaving that blank.

On a 1000 page website we can't be re-entering the title of each article into the 'Browser Page Title' box.

And therein lies the crux of the issue. The "Menu Title" top LEFT hand side of Menu Item Manager is all we want to set (along with choosing the actual article to link to).

We are contending that the article's FULL title should be used and not the Menu item's (short) title.
The Menu Item Title is the link text in the menu - and only the link text.

Just because the menu item has link text of 'short title' doesn't mean we want that as the <title>.

This is a major change of behaviour from Joomla 1.5 (and 1.0 and mambo).

Dean
Dean Marshall Consultancy - six Joomla experts - http://www.deanmarshall.co.uk/

Joomla Experts - Joomla Support http://www.deanmarshall.co.uk/joomla-se ... pport.html

User avatar
Webdongle
Joomla! Master
Joomla! Master
Posts: 36761
Joined: Sat Apr 05, 2008 9:58 pm

Re: Display article title as page title in browser

Post by Webdongle » Sat Nov 05, 2011 2:43 am

DeanMarshall wrote:....
We are contending that the article's FULL title should be used and not the Menu item's (short) title.
The Menu Item Title is the link text in the menu - and only the link text.
....
I now see what you mean. You want the Articles Title only to be overridden if a value is given to the menu items 'Browser page Title'

Which core file would contain the code ?
What would the code need to be changed to ?

Would imagine there is a file somewhere that states
If the box is empty then use the menu title
And all that would need to be replaced would be the code to call the Article Title instead ?
http://www.weblinksonline.co.uk/
https://www.weblinksonline.co.uk/updating-joomla.html
"The definition of insanity is doing the same thing over and over again, but expecting different results": Albert Einstein
Member of the CMS Release Team

User avatar
DeanMarshall
Joomla! Hero
Joomla! Hero
Posts: 2352
Joined: Fri Aug 19, 2005 2:26 am
Location: Lancaster, Lancashire, United Kingdom
Contact:

Re: Display article title as page title in browser

Post by DeanMarshall » Sat Nov 05, 2011 3:56 am

I don't know which file - but I suspect it is when article data and menu data are merged.

I think it is a bug - but as no-one else has thought it problematic it may be by design. One for the bug squad perhaps.
Dean Marshall Consultancy - six Joomla experts - http://www.deanmarshall.co.uk/

Joomla Experts - Joomla Support http://www.deanmarshall.co.uk/joomla-se ... pport.html

User avatar
Webdongle
Joomla! Master
Joomla! Master
Posts: 36761
Joined: Sat Apr 05, 2008 9:58 pm

Re: Display article title as page title in browser

Post by Webdongle » Sat Nov 05, 2011 2:02 pm

DeanMarshall wrote:....
I think it is a bug - but as no-one else has thought it problematic it may be by design. One for the bug squad perhaps.
Perhaps it was when the feature was added to the menu ? I have brought the issue up on Bugsquad but as yet no body has said anything. Personally I see your point and agree that if the 'Browser page Title' is blank then it makes more sense to default to the Article Title.

Think I found it
// Because the application sets a default page title,
// we need to get it from the menu item itself
$menu = $menus->getActive();
if ($menu)
{
$this->params->def('page_heading', $this->params->get('page_title', $menu->title));
}
else
{
$this->params->def('page_heading', JText::_('JGLOBAL_ARTICLES'));
}
/components/com_content/views/article/view.html.php
http://www.weblinksonline.co.uk/
https://www.weblinksonline.co.uk/updating-joomla.html
"The definition of insanity is doing the same thing over and over again, but expecting different results": Albert Einstein
Member of the CMS Release Team

User avatar
DeanMarshall
Joomla! Hero
Joomla! Hero
Posts: 2352
Joined: Fri Aug 19, 2005 2:26 am
Location: Lancaster, Lancashire, United Kingdom
Contact:

Re: Display article title as page title in browser

Post by DeanMarshall » Sun Nov 20, 2011 1:54 pm

Hi Wasim,

This is possible - but isn't a straightforward option - it would require some (slight) programming knowledge. The fix would be in the same file as was discussed in my blog post related to the issue being discussed in this forum thread.

http://www.deanmarshall.co.uk/deans-blo ... -view.html

Copy the file indicated from the original location, to the new location and make your edit therein.

Dean

PS: You should really have started a new forum thread (see the button labelled 'New Topic') rather than tacking a different issue on the end of an existing post. You are much more likely to get help with your own forum thread than you are this way.
Dean Marshall Consultancy - six Joomla experts - http://www.deanmarshall.co.uk/

Joomla Experts - Joomla Support http://www.deanmarshall.co.uk/joomla-se ... pport.html

AriaPlat
Joomla! Apprentice
Joomla! Apprentice
Posts: 8
Joined: Fri Nov 25, 2011 3:11 am

Re: Display article title as page title in browser

Post by AriaPlat » Mon Nov 28, 2011 1:26 am

Hi Dean,
I've followed your advice in your blog post but I'm still not getting a different result. I am not a programmer, so I cannot be certain, but I am suspicious that this 'bug' may be causing a clash in the way some templates attempt to construct the <title> on a page. Please see my forum post here about it: http://forum.joomla.org/viewtopic.php?f=616&t=676554
I hope that in the next update of Joomla 1.7.X this menu/article title issue can be resolved. I don't know why more people aren't speaking up about this, as the bug completely, in my opinion, wrecks SEO design protocols.

handy andy
Joomla! Enthusiast
Joomla! Enthusiast
Posts: 109
Joined: Fri Aug 06, 2010 1:56 pm

Re: Display article title as page title in browser

Post by handy andy » Sun Jun 03, 2012 5:36 pm

Hi,

I am way out of my depth here however my experience today may shed some light on the problem.

I was updating a site Joomla 1.5.26 and for better SEO changed the article titles to include local place names the business serves.

It worked on all articles except one, this now displays a <Title> that is neither the article title which is long or the proper menu title.

Menu title displayed on the front end is "Emergency Roof Repairs"

Article Title displayed in the browser tag is Emergency Repairs- site name (17 characters made up of three words).

Line 14 of the source code reads <title>Emergency Repairs - #### ##### ########</title>

# used to protect the customers site.

I changed Section, Catogary to match the article title but still no proper title displayed.

What is more interesting is there are some titles much longer that do display properly everywhere they should.

Perhaps the bug in 1.7 is a follow on from this unusual one in that it only happens on rare occosions which is why it has not been viewed as a major problem?

Of course I never rule out that I could have made an error somewhere however in this case I'm fairly sure I checked everything because it is important.

Anyone who wants to view the site can send me a P.M.

Thank you Dean your blog brought me here.

Andy

Update:

I deleted the offending article, section, catogary, menu and did all again using global so no back end changes were made, the old article was copied and reloaded into the new one.

Now it works, no special reason same template, no coding, maybe similar will work in 1.7 / 2.5 like I posted earlier way out of my depth.

Regards,

Andy

tarkin789
Joomla! Apprentice
Joomla! Apprentice
Posts: 47
Joined: Mon Aug 14, 2006 6:54 am

Re: Display article title as page title in browser

Post by tarkin789 » Fri Jun 08, 2012 8:49 pm

Very helpful thread. I'm still having this issue in the most recent version of 2.5, so I'm assuming the bug squad didn't deal with this.

Anyone have an update on this? Seems like a real oversight. Even a simple extension would be helpful to fix this. Seems crazy to need a template override to get this to work?

Grateful for any help...

sporttoolbars
Joomla! Intern
Joomla! Intern
Posts: 65
Joined: Sat Jan 08, 2011 6:30 pm
Contact:

Re: Display article title as page title in browser

Post by sporttoolbars » Mon Jun 25, 2012 7:07 pm

Hi there,

I'm joining the list of people who got this issue :(... i have 5k news posts and do not want to edit them all manually as you can imagine....

I tried the suggestion at the blog from Dean but could not find the exact code given there.... that changed in 2.5?.. got an update on it?

i run 2.5, can this be automated with a plugin or something?

User avatar
tdman
Joomla! Apprentice
Joomla! Apprentice
Posts: 10
Joined: Wed Jan 03, 2007 1:53 am

Re: Display article title as page title in browser

Post by tdman » Mon Jul 02, 2012 4:36 am

DeanMarshall wrote:Hi Wasim,

This is possible - but isn't a straightforward option - it would require some (slight) programming knowledge. The fix would be in the same file as was discussed in my blog post related to the issue being discussed in this forum thread.

http://www.deanmarshall.co.uk/deans-blo ... -view.html

Copy the file indicated from the original location, to the new location and make your edit therein.

Dean

PS: You should really have started a new forum thread (see the button labelled 'New Topic') rather than tacking a different issue on the end of an existing post. You are much more likely to get help with your own forum thread than you are this way.
Dean, I'm using the latest version of Joomla 2.5.6 and this problem still hasn't been fixed. I searched for a solution all day and finally came across this thread. The template override workaround on your website worked perfectly. Thank you so much for providing the solution to a problem that should have been corrected many Joomla releases ago.

I also wanted to put my sitename after the article title. Could you please tell me how to accomplish that? Thank you.

Tarti
Joomla! Apprentice
Joomla! Apprentice
Posts: 25
Joined: Sat Feb 25, 2012 12:03 pm
Contact:

Re: Display article title as page title in browser

Post by Tarti » Fri Oct 19, 2012 7:21 am

Thank you so much DeanMarshall!

page titles = article titles?! visit: http://www.deanmarshall.co.uk/deans-blo ... -view.html
All the best

teokolo
Joomla! Apprentice
Joomla! Apprentice
Posts: 8
Joined: Wed Oct 10, 2012 12:52 pm

Re: Display article title as page title in browser

Post by teokolo » Thu Nov 01, 2012 10:32 am

Hey guys, any update on this?
I'm migrating 100+ websites from joomla 1.5 to joomla 2.5 and for me this is a terrible problem.

Without a fix I need to fix about 10.000 menu items manually, setting 'Browser page Title' manually.

Template override could be a solution (and works), but replicating it for 100 websites (and tracking if a template is changed) is very annoying.


Locked

Return to “Administration Joomla! 2.5”