News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

Main Menu

Page titles do not append the site name, if defined so in J global configuration

Started by man.of.earth, August 06, 2019, 14:26:19 PM

Previous topic - Next topic

man.of.earth

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).

Ventsi Genchev

Somewhere in the forum described what should be done. I don't remember which post exactly, but I did it according to my needs.
Audio Store:
https://vsystem.bg - Bulgarian language
https://vsystem.bg/en - English

AH

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);

Regards
A

Joomla 4.4.5
php 8.1

man.of.earth

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.)

AH

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

Regards
A

Joomla 4.4.5
php 8.1

man.of.earth

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.

AH

Regards
A

Joomla 4.4.5
php 8.1

man.of.earth

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.

Milbo

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.
Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

man.of.earth

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.

GJC Web Design

Max is saying write it for the view.html.php , post it here and he will add it to the core
GJC Web Design
VirtueMart and Joomla Developers - php developers https://www.gjcwebdesign.com
VM4 AusPost Shipping Plugin - e-go Shipping Plugin - VM4 Postcode Shipping Plugin - Radius Shipping Plugin - VM4 NZ Post Shipping Plugin - AusPost Estimator
Samport Payment Plugin - EcomMerchant Payment Plugin - ccBill payment Plugin
VM2 Product Lock Extension - VM2 Preconfig Adresses Extension - TaxCloud USA Taxes Plugin - Virtuemart  Product Review Component
https://extensions.joomla.org/profile/profile/details/67210
Contact for any VirtueMart or Joomla development & customisation

AH

And make it a optional VM configuration so it does not screw up everyone elses overrides!!
Regards
A

Joomla 4.4.5
php 8.1

man.of.earth

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.

AH

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
Regards
A

Joomla 4.4.5
php 8.1

man.of.earth

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.