VirtueMart Forum

VirtueMart 2 + 3 + 4 => Security (https) / Performance / SEO, SEF, URLs => Topic started by: JakubCz on December 31, 2013, 13:20:08 PM

Title: How to remove language= from url?
Post by: JakubCz on December 31, 2013, 13:20:08 PM
Hi Guys

I'm looking for a idea of removing language= from url in my virtuamart. Url's looks now like this:

/pl/oferta/producent/iveco/samochody-ciezarowe/chlodnice-cieczy/results,211-210
- this is the default language, but this page can be accessed from this url:
/pl/oferta/producent/iveco/samochody-ciezarowe/chlodnice-cieczy/results,211-210?language=pl-PL
I want to remove default language variable from url. Any idea how to do it? This is multilanguage page.

Joomla! 2.5.16
VM 2.0.26

Title: Re: How to remove language= from url?
Post by: sadrem on December 31, 2013, 14:27:50 PM
Hi,
If You mean to remove pl in the url beginning 
Plugin manager -> Language Filter -> Remove URL Language Code to YES
if You want to remove parameter in search rezult "?language=pl-PL"  I don't know
Title: Re: How to remove language= from url?
Post by: JakubCz on January 01, 2014, 10:21:07 AM
Hi,

i know how to remove default language from the beginning of the url - but i don't know how to remove the end of url. But thanks for reply
Title: Re: How to remove language= from url?
Post by: jjk on January 01, 2014, 21:44:34 PM
Why do you want to remove that? The VM2 multilanguage system is different from Joomla's solution and the language tags are there for a reason. If you remove them, you will produce unnecessary problems. Language tags also help the search engines to determin the correct language of the content. Some of these 'ugly' urls will become indexed by the search engines, but these can be neglected. Primarily they will index the canonical urls provided by VM2, which is good for SEO.

Also I wouldn't recommend to remove the default language tag from the beginning of the url. I've seen some shops where this produced language switching problems.
Title: Re: How to remove language= from url?
Post by: JakubCz on January 02, 2014, 14:10:14 PM
VirtueMart adds this language code somewhere in code below - but i can't find where. I need to remove this parametr to remove duplicate content :)

function getOrderByList ($virtuemart_category_id = FALSE) {

$getArray = (JRequest::get ('get'));
$link = '';
$fieldLink = '';
// remove setted variable
unset ($getArray['globalCurrencyConverter'], $getArray['virtuemart_manufacturer_id'], $getArray['order'], $getArray['orderby']);

// foreach ($getArray as $key => $value )
// $fieldLink .= '&'.$key.'='.$value;
//vmdebug('getOrderByList',$getArray);
foreach ($getArray as $key => $value) {
if (is_array ($value)) {
foreach ($value as $k => $v) {
$fieldLink .= '&' . $key . '[' . $k . ']' . '=' . $v;
}
}
else {
if($key=='dir' or $key=='orderby') continue;
if(empty($value)) continue;
$fieldLink .= '&' . $key . '=' . $value;
}
}
$fieldLink[0] = "?";
$fieldLink = 'index.php' . $fieldLink;

$orderDirLink = '';
$orderDirConf = VmConfig::get ('prd_brws_orderby_dir');
$orderDir = JRequest::getWord ('dir', $orderDirConf);
if ($orderDir != $orderDirConf ) {
$orderDirLink .= '&dir=' . $orderDir; //was '&order='
}

$orderbyTxt = '';
$orderby = JRequest::getVar ('orderby', VmConfig::get ('browse_orderby_field'));
$orderby = $this->checkFilterOrder ($orderby);

$orderbyCfg = VmConfig::get ('browse_orderby_field');
if ($orderby != $orderbyCfg) {
$orderbyTxt = '&orderby=' . $orderby;
}

$manufacturerTxt = '';
$manufacturerLink = '';
if (VmConfig::get ('show_manufacturers')) {

// manufacturer link list
$virtuemart_manufacturer_id = JRequest::getInt ('virtuemart_manufacturer_id', '');
if ($virtuemart_manufacturer_id != '') {
$manufacturerTxt = '&virtuemart_manufacturer_id=' . $virtuemart_manufacturer_id;
}

// if ($mf_virtuemart_product_ids) {
$query = 'SELECT DISTINCT l.`mf_name`,l.`virtuemart_manufacturer_id` FROM `#__virtuemart_manufacturers_' . VMLANG . '` as l';
$query .= ' JOIN `#__virtuemart_product_manufacturers` AS pm using (`virtuemart_manufacturer_id`)';
$query .= ' LEFT JOIN `#__virtuemart_products` as p ON p.`virtuemart_product_id` = pm.`virtuemart_product_id` ';
$query .= ' LEFT JOIN `#__virtuemart_product_categories` as c ON c.`virtuemart_product_id` = pm.`virtuemart_product_id` ';
$query .= ' WHERE p.`published` =1';
if ($virtuemart_category_id) {
$query .= ' AND c.`virtuemart_category_id` =' . (int)$virtuemart_category_id;
}
$query .= ' ORDER BY l.`mf_name`';
$this->_db->setQuery ($query);
$manufacturers = $this->_db->loadObjectList ();
// vmdebug('my manufacturers',$this->_db->getQuery());
$manufacturerLink = '';
if (count ($manufacturers) > 0) {
$manufacturerLink = '<div class="orderlist">';
if ($virtuemart_manufacturer_id > 0) {
$manufacturerLink .= '<div><a title="" href="' . JRoute::_ ($fieldLink . $orderbyTxt . $orderDirLink , FALSE) . '">' . JText::_ ('COM_VIRTUEMART_SEARCH_SELECT_ALL_MANUFACTURER') . '</a></div>';
}
if (count ($manufacturers) > 1) {
foreach ($manufacturers as $mf) {
$link = JRoute::_ ($fieldLink . '&virtuemart_manufacturer_id=' . $mf->virtuemart_manufacturer_id . $orderbyTxt . $orderDirLink,FALSE);
if ($mf->virtuemart_manufacturer_id != $virtuemart_manufacturer_id) {
$manufacturerLink .= '<div><a title="' . $mf->mf_name . '" href="' . $link . '">' . $mf->mf_name . '</a></div>';
}
else {
$currentManufacturerLink = '<div class="title">' . JText::_ ('COM_VIRTUEMART_PRODUCT_DETAILS_MANUFACTURER_LBL') . '</div><div class="activeOrder">' . $mf->mf_name . '</div>';
}
}
}
elseif ($virtuemart_manufacturer_id > 0) {
$currentManufacturerLink = '<div class="title">' . JText::_ ('COM_VIRTUEMART_PRODUCT_DETAILS_MANUFACTURER_LBL') . '</div><div class="activeOrder">' . $manufacturers[0]->mf_name . '</div>';
}
else {
$currentManufacturerLink = '<div class="title">' . JText::_ ('COM_VIRTUEMART_PRODUCT_DETAILS_MANUFACTURER_LBL') . '</div><div class="Order"> ' . $manufacturers[0]->mf_name . '</div>';
}
$manufacturerLink .= '</div>';
}
// }
}

/* order by link list*/
$orderByLink = '';
$fields = VmConfig::get ('browse_orderby_fields');
if (count ($fields) > 1) {
$orderByLink = '<div class="orderlist">';
foreach ($fields as $field) {
if ($field != $orderby) {

$dotps = strrpos ($field, '.');
if ($dotps !== FALSE) {
$prefix = substr ($field, 0, $dotps + 1);
$fieldWithoutPrefix = substr ($field, $dotps + 1);
// vmdebug('Found dot '.$dotps.' $prefix '.$prefix.'  $fieldWithoutPrefix '.$fieldWithoutPrefix);
}
else {
$prefix = '';
$fieldWithoutPrefix = $field;
}

$text = JText::_ ('COM_VIRTUEMART_' . strtoupper ($fieldWithoutPrefix));

$field = explode('.',$field);
if(isset($field[1])){
$field = $field[1];
} else {
$field = $field[0];
}
$link = JRoute::_ ($fieldLink . $manufacturerTxt . '&orderby=' . $field,FALSE);

$orderByLink .= '<div><a title="' . $text . '" href="' . $link . '">' . $text . '</a></div>';
}
}
$orderByLink .= '</div>';
}


if($orderDir == 'ASC'){
$orderDir = 'DESC';
} else {
$orderDir = 'ASC';
}

if ($orderDir != $orderDirConf ) {
$orderDirLink = '&dir=' . $orderDir; //was '&order='
} else {
$orderDirLink = '';
}

$orderDirTxt = JText::_ ('COM_VIRTUEMART_SEARCH_ORDER_'.$orderDir);

$link = JRoute::_ ($fieldLink . $orderbyTxt . $orderDirLink . $manufacturerTxt,FALSE);

// full string list
if ($orderby == '') {
$orderby = $orderbyCfg;
}
$orderby = strtoupper ($orderby);


$dotps = strrpos ($orderby, '.');
if ($dotps !== FALSE) {
$prefix = substr ($orderby, 0, $dotps + 1);
$orderby = substr ($orderby, $dotps + 1);
// vmdebug('Found dot '.$dotps.' $prefix '.$prefix.'  $fieldWithoutPrefix '.$fieldWithoutPrefix);
}
else {
$prefix = '';
// $orderby = $orderby;
}
$orderByList = '<div class="orderlistcontainer"><div class="title">' . JText::_ ('COM_VIRTUEMART_ORDERBY') . '</div><div class="activeOrder"><a title="' . $orderDirTxt . '" href="' . $link . '">' . JText::_ ('COM_VIRTUEMART_SEARCH_ORDER_' . $orderby) . ' ' . $orderDirTxt . '</a></div>';

$orderByList .= $orderByLink . '</div>';

$manuList = '';
if (VmConfig::get ('show_manufacturers')) {
if (empty ($currentManufacturerLink)) {
$currentManufacturerLink = '<div class="title">' . JText::_ ('COM_VIRTUEMART_PRODUCT_DETAILS_MANUFACTURER_LBL') . '</div><div class="activeOrder">' . JText::_ ('COM_VIRTUEMART_SEARCH_SELECT_MANUFACTURER') . '</div>';
}
$manuList = ' <div class="orderlistcontainer">' . $currentManufacturerLink;
$manuList .= $manufacturerLink . '</div><div class="clear"></div>';

}

return array('orderby'=> $orderByList, 'manufacturer'=> $manuList);
}
Title: Re: How to remove language= from url?
Post by: jjk on January 02, 2014, 14:18:44 PM
You don't have to remove the language tag for 'duplicate content' reasons. Search engines know that there are usually many urls in shops pointing to the same product page. The canonical url of a product points all major search engines to the primary url.
Title: Re: How to remove language= from url?
Post by: JakubCz on January 02, 2014, 14:25:41 PM
This is not cannonical page - this is duplicate page - content on this page is exactly the same, not similar. It must be redirect. Trust me, i'am SEO Director from SEO Agency ;) But i'm still don't know how language code is adding to url in getOrderByList function. Any idea?
Title: Re: How to remove language= from url?
Post by: jjk on January 02, 2014, 15:33:48 PM
Quote from: JakubCz on January 02, 2014, 14:25:41 PM
...Trust me, i'am SEO Director from SEO Agency ;)
Hehe,  :), ...and I usually have no problem to place my products into top positions (often No 1) on Google...

I'm not a coder, so I can't give hints on how to hack the code. However, the source code of both of your sample urls will contain a link to the canonical version of this page, and that cures the duplicate content problem according to Matt Cutts. BTW - you can replace ?language=pl-PL at the end of your url with any garbage characters you like and it will still find that page!  ;)