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).
Somewhere in the forum described what should be done. I don't remember which post exactly, but I did it according to my needs.
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);
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.)
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
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.
Then apply the override to the template I showed earlier :-)
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.
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.
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.
Max is saying write it for the view.html.php , post it here and he will add it to the core
And make it a optional VM configuration so it does not screw up everyone elses overrides!!
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.
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
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.
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.