Can't set custom Page Title in Item Menu ( VM Front Page )

Started by luizwbr, February 07, 2013, 20:08:06 PM

Previous topic - Next topic

luizwbr

Hi everyone. Just to take this bug more 'formal' :)

I can't change page title using VM front page layout, only setting in Menu Params.

I discovered why: Line 158 on /public_html/components/com_virtuemart/views/virtuemart/view.html.php

$document->setTitle(JText::sprintf('COM_VIRTUEMART_HOME',$vendor->vendor_store_name));

Always set the page title to COM_VIRTUEMART_HOME + $vendor->vendor_store_name, even if exist a SEO plugin to replace it.

To FIX:

Just change line 158 on virtuemart view to this entire code block:

$app = JFactory::getApplication();
$menus = $app->getMenu();
$menu = $menus->getActive();
if ($menu) $title = $menu->title;

$params = new JParameter($menu->params);
$custom_pagetitle = $params->get('page_title');

if (empty($custom_pagetitle)) {
$document->setTitle(JText::sprintf('COM_VIRTUEMART_HOME',$vendor->vendor_store_name));
}


I tested this on VM 2.0.18a, Joomla 2.5.9

To category, already has a field to fill with the custom page title and works ( don't replace entire title, but the text appear in Browser title ).

http://virtuemartbrasil.com.br - Brazillian VirtueMart official Support Group
http://loja.weber.eti.br - Paid Plugins for Virtuemart Brasil
https://www.facebook.com/groups/virtuemartpro/ - Brazillian VirtueMart group on Facebook

mmally

in VM 2.0.18b (maybe also in previous versions) you just need to remove some lines, because the $document->page_title is already set correct in line 147 $document = JFactory::getDocument() using joomla functions, which consider custom titles set in the params

So here is my solution, which does not require to add any funtion calls, but removes some of them.

In /components/com_virtuemart/views/virtuemart/view.html.php remove lines 154 to 160.

original code beginning in line 147
# Set the titles
$document = JFactory::getDocument();

$error = JRequest::getInt('error',0);

//Todo this may not work everytime as expected, because the error must be set in the redirect links.
if(!empty($error)){
$document->setTitle(JText::_('COM_VIRTUEMART_PRODUCT_NOT_FOUND').JText::sprintf('COM_VIRTUEMART_HOME',$vendor->vendor_store_name));
} else {
$app = JFactory::getApplication();
$menus = $app->getMenu();
$menu = $menus->getActive();
if ($menu) $title = $menu->title;
if(empty($title)) $title = JText::sprintf('COM_VIRTUEMART_HOME',$vendor->vendor_store_name);
$document->setTitle($title);[/b]
}


fixed code beginning in line 147
# Set the titles
$document = JFactory::getDocument();

$error = JRequest::getInt('error',0);

//Todo this may not work everytime as expected, because the error must be set in the redirect links.
if(!empty($error)){
$document->setTitle(JText::_('COM_VIRTUEMART_PRODUCT_NOT_FOUND').JText::sprintf('COM_VIRTUEMART_HOME',$vendor->vendor_store_name));
}

lindapowers

So I wasn't mad after all, I wonder how it was possible that only a few had noticed it http://forum.virtuemart.net/index.php?topic=113392.msg381771#msg381771

Thanks guys, please add this fix to the core, changing the title from the frontpage of the shop is really important for SEO.


Milbo

Should I fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/