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

Site name in page title

Started by tonis, April 16, 2014, 11:22:02 AM

Previous topic - Next topic

tonis

Hello

In every version I install, I must do this modification, so it would be great to implement this in the next versions. I dont know why VM ignores the default joomla configuration, to showing the site name in page titles. So I made this. It matches the default configuration. Its now only for categories and product, but it should not be hard to implement this in all other views.

Site name in category title
components\com_virtuemart\views\category\view.html.php
line 263

if ($virtuemart_manufacturer_id>0 and !empty($products[0])) $title .=' '.$products[0]->mf_name ;

/* add site name config */
if (empty($title)) {
$title = $app->getCfg('sitename');
}
elseif ($app->getCfg('sitename_pagetitles', 0) == 1) {
$title = JText::sprintf('JPAGETITLE', $app->getCfg('sitename'), $title);
}
elseif ($app->getCfg('sitename_pagetitles', 0) == 2) {
$title = JText::sprintf('JPAGETITLE', $title, $app->getCfg('sitename'));
}
/* add site name config end */

$document->setTitle( $title );


Site name in product title
components\com_virtuemart\views\productdetails\view.html.php
line 190

// $document->setTitle should be after the additem pathway
/* if ($product->customtitle) {
    $document->setTitle(strip_tags($product->customtitle));
} else {
    $document->setTitle(strip_tags(($category->category_name ? ($category->category_name . ' : ') : '') . $product->product_name));
}
*/


/* add site name config */
if (!empty($product->customtitle)) {
    $title = strip_tags($product->customtitle);
} else {
    $title = strip_tags(($category->category_name ? ($category->category_name . ' : ') : '') . $product->product_name);
}

$app = JFactory::getApplication();

if (empty($title)) {
$title = $app->getCfg('sitename');
}
elseif ($app->getCfg('sitename_pagetitles', 0) == 1) {
$title = JText::sprintf('JPAGETITLE', $app->getCfg('sitename'), $title);
}
elseif ($app->getCfg('sitename_pagetitles', 0) == 2) {
$title = JText::sprintf('JPAGETITLE', $title, $app->getCfg('sitename'));
}

$document->setTitle( $title );
/* add site name config end */



also, I think that it is not necessary to have in product title the category name, in majority of cases it is the product name which is important, not the path to product,
also google shows only about firts 60 characters from the title, and the category name can be to long to show also the product name in the search results, which is not good for customer and also for a good SEO
maybe it would be better to swich the order .... product - category - site .... or completely remove the category name

this would be enough
// $document->setTitle should be after the additem pathway
/* if ($product->customtitle) {
    $document->setTitle(strip_tags($product->customtitle));
} else {
    $document->setTitle(strip_tags(($category->category_name ? ($category->category_name . ' : ') : '') . $product->product_name));
}
*/


/* add site name config */
if (!empty($product->customtitle)) {
    $title = strip_tags($product->customtitle);
} else {
    $title = strip_tags($product->product_name);
}

$app = JFactory::getApplication();

if (empty($title)) {
$title = $app->getCfg('sitename');
}
elseif ($app->getCfg('sitename_pagetitles', 0) == 1) {
$title = JText::sprintf('JPAGETITLE', $app->getCfg('sitename'), $title);
}
elseif ($app->getCfg('sitename_pagetitles', 0) == 2) {
$title = JText::sprintf('JPAGETITLE', $title, $app->getCfg('sitename'));
}

$document->setTitle( $title );
/* add site name config end */


good luck to everyone

J 2.5.19
VM 2.6.0