VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: man.of.earth on August 06, 2019, 14:26:19 PM

Title: Page titles do not append the site name, if defined so in J global configuration
Post by: man.of.earth on August 06, 2019, 14:26:19 PM
Hello everyone,

I see that VM page titles do not take into consideration the settings made in global configuration in Joomla (append site name before or after the current page title).
Title: Re: Page titles do not append the site name, if defined so in J global configuration
Post by: Ventsi Genchev on August 06, 2019, 16:15:49 PM
Somewhere in the forum described what should be done. I don't remember which post exactly, but I did it according to my needs.
Title: Re: Page titles do not append the site name, if defined so in J global configuration
Post by: AH on August 06, 2019, 16:51:28 PM
Correct it does not do this - you need a page override

In category default.php


//Overrides the meta page title set int the view.html
$Jconfig = JFactory::getConfig();
$qsitename = $Jconfig->get('sitename');
$document = JFactory::getDocument ();

//adds title of category name with sitename
$document->setTitle($this->category->category_name . ' - '. $qsitename);

//could use existing title and append sitename - which would cater for manual entry
//$document->setTitle($document->title . ' - '. $qsitename);

Title: Re: Page titles do not append the site name, if defined so in J global configuration
Post by: man.of.earth on August 20, 2019, 11:49:59 AM
I use that, but it is something that should be modified in the core, for all pages involved (not only categories and products, but also checkout, my orders etc.)
Title: Re: Page titles do not append the site name, if defined so in J global configuration
Post by: AH on August 20, 2019, 16:00:54 PM
Quotebut it is something that should be modified in the core, for all pages involved (not only categories and products, but also checkout, my orders etc.)

But for some - this is not what would be wanted as it would reduce the readability of product name

There is no need to add to checkout or my orders - they are never referenced anywhere so the click through advantage is meaningless

Title: Re: Page titles do not append the site name, if defined so in J global configuration
Post by: man.of.earth on August 24, 2019, 17:34:37 PM
It's good for SEO though. Product title would go first, and site name in the end, so it would be easily readable in Google results.
Title: Re: Page titles do not append the site name, if defined so in J global configuration
Post by: AH on August 24, 2019, 20:48:59 PM
Then apply the override to the template I showed earlier :-)
Title: Re: Page titles do not append the site name, if defined so in J global configuration
Post by: man.of.earth on August 27, 2019, 17:29:44 PM
I said I'm already using that [template override]. I simply pointed out that that option should be somewhere in the core, so to not be necessary to modify the templates.
Title: Re: Page titles do not append the site name, if defined so in J global configuration
Post by: Milbo on August 27, 2019, 18:05:33 PM
I agree with you. When you can write an override, ...

check the category view, the file view.html.php line 479 (in the new core vm3.6) and then just add it and write the code here.
Title: Re: Page titles do not append the site name, if defined so in J global configuration
Post by: man.of.earth on August 27, 2019, 18:26:15 PM
The file view.html.php is not overrideable.
The disadvantages of having to make modifications in the core is that they must be done every time the core changes.
I did them in the template.
Title: Re: Page titles do not append the site name, if defined so in J global configuration
Post by: GJC Web Design on August 27, 2019, 19:29:35 PM
Max is saying write it for the view.html.php , post it here and he will add it to the core
Title: Re: Page titles do not append the site name, if defined so in J global configuration
Post by: AH on August 27, 2019, 21:48:34 PM
And make it a optional VM configuration so it does not screw up everyone elses overrides!!
Title: Re: Page titles do not append the site name, if defined so in J global configuration
Post by: man.of.earth on August 28, 2019, 02:12:02 AM
For category, it could be
$includeSiteName = (int) JFactory::getApplication()->getCfg('sitename_pagetitles');
$category_id  = vRequest::getInt ('virtuemart_category_id', 0);
if ($includeSiteName && $category_id != 0){
$document = JFactory::getDocument();
$siteName = JFactory::getApplication()->getCfg('sitename');
$docTitle = $document->getTitle();
switch ($includeSiteName){
case 1;
$document->setTitle($siteName . ' - ' . $docTitle);
break;
case 2;
$document->setTitle($docTitle . ' - ' . $siteName);
break;
}
}


For product page:
$includeSiteName = (int) JFactory::getApplication()->getCfg('sitename_pagetitles');
if ($includeSiteName){
$document = JFactory::getDocument();
$siteName = JFactory::getApplication()->getCfg('sitename');
$docTitle = $document->getTitle();
switch ($includeSiteName){
case 1;
$document->setTitle($siteName . ' - ' . $docTitle);
break;
case 2;
$document->setTitle($docTitle . ' - ' . $siteName);
break;
}
}


(I'm actually using these pieces of code.)

If both snippets are used, the title on a product page will be
Product Name - Category - Site name for Site title set to "after" in global configuration (which looks good and it's comprehensible by humans and search engines :) )

I was wondering if that kind of code can be added more into the core, so it could be used more simply for all the pages (including checkout, my orders etc.). In this case, the two snippets could be combined somehow, to select automatically if it's a category or some other VM page.
Title: Re: Page titles do not append the site name, if defined so in J global configuration
Post by: AH on August 28, 2019, 09:54:10 AM
The modifications needs to go into the relevant view.html

It should to be a VM config that is not switched on by default

Consider using a parameter e.g.:
VmConfig::get('appendsitename',0),

Doing an override is simple, as you are doing it for yourself

If you want things into core - you have to give an option of configuration so that this does not impact sites already in production

If you look at this will give you an idea of where metadata is set by VM - that would require adjustment to cater for your specific instance and move into core

\components\com_virtuemart\views\category\view.html.php
Title: Re: Page titles do not append the site name, if defined so in J global configuration
Post by: man.of.earth on August 28, 2019, 12:01:40 PM
The snippets above use the setting from the global configuration, and they obviously do not automatically turn on the "append site name in the title option" (so if it's turned on, it's on for the entire website, including VM).
In case these snippets (or a combination of them) cannot be added more into the core, the second one above could be used for all VM views, either in the view.html.php files, or in the default.php files for each view.
Title: Re: Page titles do not append the site name, if defined so in J global configuration
Post by: AH on August 28, 2019, 12:35:18 PM
arcturus

Thank you for your feedback

I am aware of what your code does and the configuration it utilises from Joomla core.

If this were to be considered for core - The dev team will still have consider the impact this might have on existing installations as this behaviour is new.