Elxis CMS Forum

Support => General => Topic started by: kyomar on September 14, 2019, 05:29:51

Title: Article in category no site name added in page title [solved]
Post by: kyomar on September 14, 2019, 05:29:51
Hi, I just noticed that when I open an article belonging to a category the site name is not added at the end of the page title.
Example:
- article no category; page title = article title - site name
- category; page title = category title - site name
- article within category; page title = article title - category title - (empty - no site name)
Is this by design? How can I add site name? I am using Elxis 5 and five template.

Thank you!
Title: Re: Article in category no site name added in page title
Post by: webgift on September 23, 2019, 16:34:13

As far as i can see sitename is added when we have articles without category (autonomous
articles). You could apply the following change:

File: components/com_content/controllers/article.php
Line: 146

Change the following line:
$eDoc->setTitle($row->title.' - '.$category_title.$page_extra);


to:
$eDoc->setTitle($row->title.' - '.$category_title.$page_extra.' - '.$elxis->getConfig('SITENAME'));

Take under consideration that sitename should contain up to 70 characters in length.
Title: Re: Article in category no site name added in page title
Post by: kyomar on September 24, 2019, 10:45:42
Thanks a lot webgift; changed the code and all good. I think the sitename should always be added.

I have just noticed that the category title resp. sitename is added to the description, which doesn't make sense to me. Do I have to change these lines:
if ($category_title != '') { $eDoc->setDescription($desc.' '.$category_title.$page_extra); }
else { $eDoc->setDescription($desc.$page_extra.' '.$elxis->getConfig('SITENAME')); }

to this:
if ($category_title != '') { $eDoc->setDescription($desc); }
else { $eDoc->setDescription($desc.$page_extra)); }

Thank you!
Title: Re: Article in category no site name added in page title
Post by: webgift on September 24, 2019, 20:43:00

You're welcome!
If you need the sitename then you should add the following line 
$elxis->getConfig('SITENAME'));
in both cases.

It's nice to separate the meta description when you have a category_title or not. So
it's up to your desire!
Title: Re: Article in category no site name added in page title
Post by: kyomar on September 25, 2019, 10:27:06
Thanks webgift. I don't need the sitename or category title after meta description like in the attached screenshot. I am sorry but I am still not sure whether the code change I suggested is correct to remove sitename/category title? Would be great if you could verify.
Thank you!
Title: Re: Article in category no site name added in page title
Post by: webgift on September 26, 2019, 11:59:49
We're talking about Meta Title and it's been changed to Description.
In case that you would like to remove these from Meta Description tag then you should
change the following:
     
if ($category_title != '') {
   $eDoc->setDescription($desc.' '.$category_title.$page_extra);
} else {
   $eDoc->setDescription($desc.$page_extra.' '.$elxis->getConfig('SITENAME'));
}


With these one:
     
/* if ($category_title != '') {
   $eDoc->setDescription($desc.' '.$category_title.$page_extra);
} else {
   $eDoc->setDescription($desc.$page_extra.' '.$elxis->getConfig('SITENAME'));
}*/
$eDoc->setDescription($desc.' '.$page_extra);

page_extra is required in order to separate the Meta Description within pages.
Category title would be nice to keep if you would like my opinion.
Title: Re: Article in category no site name added in page title
Post by: kyomar on September 26, 2019, 12:31:24
Many thanks webgift for the correct code and I am sorry for the confusion changing the subject from Meta Title to Meta Description. Anyhow, I really don' t understand why you think it's nice to have Category or Sitename added to the description. I don't see the benefit and the category title and sitename are already shown in the Page Title. I guess I am missing something :-).
Thanks again and have a nice day!
Title: Re: Article in category no site name added in page title [solved]
Post by: webgift on September 27, 2019, 09:05:11

You're welcome @kyomar
More data in Meta tag could be used mainly for two reasons: