News:

Looking for documentation? Take a look on our wiki

Main Menu

Custom Page Title in Virtuemart 3

Started by capricorn, June 05, 2015, 20:14:16 PM

Previous topic - Next topic

capricorn

Hello,

How could I change the browser page title in VM 3.0.8? For instance, I would like all parent categories, SKU and the Shop Name to be included in it. What I can see now is the last parent category and the product name only like that <title>Category Name : Product Name</title>

Regards

jjk

You could use the 'Custom Page Title' in the meta information section of the product description tab.
Or you would have to change the code in yourdomain\components\com_virtuemart\views\productdetails\view.html.php (somewhere around line 237) in VM 3.0.9.
However, the SKU in the page title might only be useful if you are sure that your customers are searching directly for the SKU in the search engines.
Non-English Shops: Are your language files up to date?
http://virtuemart.net/community/translations

capricorn

#2
Thanks,

I figured it out. One more question please.

I'm using sh404SEF. Before there was a lot of control over VM SEF in scope of that component.

Why do you constantly re-write your router as I have heard from sh404SEF developers? What is on plan with regard to sh404SEF?

Cheers

Studio 42

Hi,

You can override the view to change page title.
file is : JOOMLAROOT\components\com_virtuemart\views\productdetails\tmpl\default.php
Best is to copy the file in your template.  see : https://docs.joomla.org/How_to_override_the_output_from_the_Joomla!_core

Now the code to add in default.php file for eg.
$document = JFactory::getDocument();
$newTitle = '';
// Set the titles
if ($this->product->customtitle) {
$document->setTitle(strip_tags(html_entity_decode($this->product->customtitle,ENT_QUOTES)));
} else {
// categories
if ($this->category->parents) {
foreach ($this->category->parents as $c) {
if(is_object($c) and isset($c->category_name)){
$newTitle .= $c->category_name.' - ';
}
}
}
$newTitle .= $this->category->category_name. ' : '.$this->product->product_name.' ('.$this->product->product_sku.')';
$document->setTitle(strip_tags(html_entity_decode($newTitle,ENT_QUOTES)));
}


Note: i don't have test the code validity. If you need sitename use JFactory::getApplication()->getCfg('sitename');.

Patrick

jjk

Quote from: capricorn on July 21, 2015, 00:47:12 AM
I'm using sh404SEF. Before there was a lot of control over VM SEF in scope of that component.

Personally I stopped using sh404sef when Joomla 1.6 was released, because concerning SEF-URLs I can achieve the same urls with native Joomla SEF and VM SEF settings. Might require a little bit more thinking when planning the site structure, but once done the result is much less maintenance work and a faster site.

QuoteWhy do you constantly re-write your router as I have heard from sh404SEF developers? What is on plan with regard to sh404SEF?

The primary problem is the lousy Joomla 3.x router system. Have a look here:
http://issues.joomla.org/tracker/joomla-cms/?state=1&sort=issue&direction=desc&user=undefined&category=router-sef&stools-active=1
You may toggle between closed (fixed) and open router issues to see the number of changes. And when they change something, it often breaks something in Virtuemart. So with every new Joomla release the VirtueMart developers have to spend a lot of time trying to provide a fix for the Joomla router/language fixes. We hope the Joomla router will become more stable after the currently open pull requests by 'Hackwar' are implemented in Joomla 3.5. But the best solution would be if an excellent developer with rock-solid router knowledge would write a VM component router which would make VM independent from the Joomla router.
Non-English Shops: Are your language files up to date?
http://virtuemart.net/community/translations

capricorn

@ jjk and Studio 42.

Thanks to both of you for your advice. Finally, I went along Patrick's way due to safe updates. The code provided is working as far as I tested it. I only removed from there a category name since it was already present in the Page Title. Many thanks again Patrick.

Cheers