VirtueMart Forum

VirtueMart 2 + 3 + 4 => Virtuemart Development and bug reports => Topic started by: leFlea on October 14, 2012, 15:55:46 PM

Title: Include Site Name in Page Titles
Post by: leFlea on October 14, 2012, 15:55:46 PM
Is there a hack or fix for including site name in page titles?

Joomla 2.5 has a new global setting for "Include Site Name in Page Titles". Can be set to Before or After or No. This doesn't work in VM2.0.12b.
e.g. When viewing category page instead of just showing category name on page title: "Furniture" would like it to be "Furniture - Hacienda Crafts Co."
Title: Re: Include Site Name in Page Titles
Post by: cmb on November 03, 2012, 19:24:13 PM
It doesn't work in VirtueMart version 2.0.12f either.
Joomla 2.5.7
Title: Re: Include Site Name in Page Titles
Post by: CE WebDesign München on December 07, 2012, 13:10:36 PM
hi, for VM 2.0.14:)
FOR CATEGORY:
\components\com_virtuemart\views\category\view.html.php (LINE 188)
REPLACE:
      $document->setTitle( $title );
WITH:
      $document->setTitle(JFactory::getApplication()->getCfg('sitename').' -> '.$title);
      
FOR PRODUCTS:
\components\com_virtuemart\views\productdetails\view.html.php (LINE 213)
REPLACE:
      $document->setTitle( strip_tags(($category->category_name?($category->category_name.' - '):'').$product->product_name));
WITH:
       $document->setTitle(JFactory::getApplication()->getCfg('sitename').' -> '.strip_tags(($category->category_name ? ($category->category_name . ' -> '): '') . $product->product_name));
      
      
if you want to do it without hack, edit:
Category->Product Category Form->Meta Information->Custom Page Title
Product->Product Description->Meta Information->Custom Page Title
Title: Re: Include Site Name in Page Titles
Post by: dblaze on September 29, 2013, 17:07:43 PM
Or more fancyer way, u mkae template overrides and include all options.... just put this in every default.php template ur using (category, productdetails, etc.)

/* BEGIN Virtuemart Title Fix */
$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;
    }
}
/* END Virtuemart Title Fix */
Title: Re: Include Site Name in Page Titles
Post by: CE WebDesign München on September 29, 2013, 19:19:56 PM
hi dblaze, works for me,
thank you very much for sharing this, really helpfull!!!   8)