VirtueMart Forum

VirtueMart 2 + 3 + 4 => Frontend Modules => Topic started by: adirz8 on November 27, 2016, 22:31:21 PM

Title: Include Site Name in Page Titles in browser title
Post by: adirz8 on November 27, 2016, 22:31:21 PM
Hi , How I can Include my site name in page title
like" page title - site name".
it is only  pages of virtuemart.
site url: http://www.thedealers.co.il/
VirtueMart 3.0.18, Joomla! 3.6.4.
Thanks,
Title: Re: Include Site Name in Page Titles in browser title
Post by: AH on November 28, 2016, 09:59:35 AM
Use the joomla setting in global configuration

seo settings /Include site name in titles

Title: Re: Include Site Name in Page Titles in browser title
Post by: adirz8 on November 28, 2016, 16:34:34 PM
it is not working! I try many times.
Title: Re: Include Site Name in Page Titles in browser title
Post by: mcmannehan2002 on November 28, 2016, 16:42:03 PM
May be this should help:
https://docs.joomla.org/J3.x:Global_configuration (https://docs.joomla.org/J3.x:Global_configuration)
Title: Re: Include Site Name in Page Titles in browser title
Post by: sandomatyas on September 10, 2018, 15:14:41 PM
It's still doesn't work. When I enable "Site Name in Page Titles" it works everywhere except with VirtueMart which just ignores this setting.
Title: Re: Include Site Name in Page Titles in browser title
Post by: AH on September 10, 2018, 16:07:29 PM
VM does not honour this Joomla setting for product/categories etc
Title: Re: Include Site Name in Page Titles in browser title
Post by: sandomatyas on September 12, 2018, 20:30:53 PM
And shouldn't it? After all this is a global setting for the whole site
Title: Re: Include Site Name in Page Titles in browser title
Post by: AH on September 13, 2018, 09:25:33 AM
Some people will want it to appear on their category/product pages other people will not.

At the present time - it does not appear
Title: Re: Include Site Name in Page Titles in browser title
Post by: GJC Web Design on September 13, 2018, 09:40:22 AM
It would be a relatively small task to append the site name to the existing Html title.. u could do it in the template over rides

something like

$document = JFactory::getDocument();
$title = $document->getTitle;
$config = JFactory::getConfig();
$sitename = $config->get( 'sitename' );
$document->setTitle($sitename.' | '.$title);

not tried or tested
Title: Re: Include Site Name in Page Titles in browser title
Post by: Ventsi Genchev on September 13, 2018, 10:23:22 AM
For categories:
/templates/your_theme/html/com_virtuemart/category/default.php
For products:
/templates/your_theme/html/com_virtuemart/productdetails/default.php


$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;
    }
}


Tested and worked.
If the main page is a category, an ID check must be done to avoid duplicating the site name.
Title: Re: Include Site Name in Page Titles in browser title
Post by: Ventsi Genchev on September 13, 2018, 11:02:18 AM
For categories with main page check (does not add to the main page):
/templates/your_theme/html/com_virtuemart/category/default.php


$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;
    }
}
Title: Re: Include Site Name in Page Titles in browser title
Post by: Typhoon365 on September 14, 2018, 08:45:55 AM
Would love this to be incorporated into the core code.

Seems quite a few of us need site name in our page titles.

Understand we can do it as an override, but having overrides for basic functionality like this is a pain. Everytime we do a Virtuemart and 3rd template update to get the latest, we need to re-implement again.
Title: Re: Include Site Name in Page Titles in browser title
Post by: jjk on September 15, 2018, 11:33:27 AM
Quote from: Typhoon365 on September 14, 2018, 08:45:55 AM
Seems quite a few of us need site name in our page titles.

I'm using an override which adds the manufacturer name into the browser page title of product views. Anyway, whatever you add, take into consideration that Google cuts off the title after 70 characters (often less, depending on the width of characters in the title). In case that you add the site name in front, the product name (keywords) moves towards the end of the line, which might result in lower ranking and also the displayed product name might become truncated in Google search results. Another disadvantage with the site name in front of the browser page title is, that all open browser tabs might show only site name and the user can see the rest only if he places his mouse pointer over the tab.
Title: Re: Include Site Name in Page Titles in browser title
Post by: AH on September 15, 2018, 19:35:48 PM
I use an override for the category page titles to include the sitename - very similar to @GJC version

But slightly different using category name | sitename