Virtuemart 3.0.14, Joomla 3.5.1, multilanguage site
Problem:The cart popup link and the continues shopping link are prepared with a function, which does not supporting SEO.
This is not what I expected.
When I click on button "continues shopping" in inside the Cart view with a language other than English, suddenly the language of the popup changes from that language to the English language.
--
SolutionI was surprised looking at the function prepareContinueLink(); and after testing, I found a solution and could simplify that link creation, like:
components/com_virtuemart/helpers/vmview.php at LINE 114 Before function prepareContinueLink(){
$virtuemart_category_id = shopFunctionsF::getLastVisitedCategoryId ();
$categoryStr = '';
if ($virtuemart_category_id) {
$categoryStr = '&virtuemart_category_id=' . $virtuemart_category_id;
}
$ItemidStr = '';
$Itemid = shopFunctionsF::getLastVisitedItemId();
if(!empty($Itemid)){
$ItemidStr = '&Itemid='.$Itemid;
}
$lang = '';
if(VmConfig::$jLangCount>1 and !empty(VmConfig::$vmlangSef)){
$lang = '&lang='.VmConfig::$vmlangSef;
}
$this->continue_link = JURI::root() .'index.php?option=com_virtuemart&view=category' . $categoryStr.$lang.$ItemidStr;
$this->continue_link_html = '<a class="continue_link" href="' . $this->continue_link . '">' . vmText::_ ('COM_VIRTUEMART_CONTINUE_SHOPPING') . '</a>';
$juri = JUri::getInstance()->toString(array( 'host', 'port'));
$scheme = 'http';
if(VmConfig::get('useSSL',false)){
$scheme .='s';
}
$this->cart_link = $scheme.'://'.$juri. JURI::root(true).'/index.php?option=com_virtuemart&view=cart'.$lang;
return;
}
Now: function prepareContinueLink(){
$virtuemart_category_id = shopFunctionsF::getLastVisitedCategoryId();
$categoryStr = '';
if ($virtuemart_category_id) {
$categoryStr = '&virtuemart_category_id=' . $virtuemart_category_id;
}
$this->continue_link = JRoute::_('index.php?option=com_virtuemart&view=category' . $categoryStr);
$this->continue_link_html = '<a class="continue_link" href="' . $this->continue_link . '">' . vmText::_ ('COM_VIRTUEMART_CONTINUE_SHOPPING') . '</a>';
$this->cart_link = JRoute::_('index.php?option=com_virtuemart&view=cart', false, VMConfig::get('useSSL', 0) );
return;
}
Explanation:
- No SEO
- No need to handle the language string because JRoute do this itself
- Itemid is also handled via JRoute
- scheme (http and https) handling was not correct, when you are already on https it switches back to http if useSSL was 0 - only if useSSL was enabled, the link was created with https; this is now inside JRoute; now it does not switch from https back to http if useSLL is disabled
Please test this code, thank you.
Thomas
It's better to discus this inside here...
Referring to: https://forum.virtuemart.net/index.php?topic=133489.msg464919#msg464919 (https://forum.virtuemart.net/index.php?topic=133489.msg464919#msg464919)
How I said in the other thread. I didn't had time to test this code, but if I'm not mistaken your code does not change the mentioned behaviour.
This code
if(VmConfig::get('useSSL',false)){
$scheme .='s';
}
$this->cart_link = $scheme.'://'.$juri. JURI::root(true).'/index.php?option=com_virtuemart&view=cart'.$lang;
and your code
$this->cart_link = JRoute::_('index.php?option=com_virtuemart&view=cart', false, VMConfig::get('useSSL', 0) );
behave exactly the same way if useSSL is false. Or does JRoute ignore this parameter if "Force SSL" is enabled in the Joomla Configuration??
Quotebehave exactly the same way if useSSL is false. Or does JRoute ignore this parameter if "Force SSL" is enabled in the Joomla Configuration??
No, it is not the same way! Please correct your message above.
When 0, it keeps it as it is - ignore the parameter from Virtuemart.
If 1, it switches to https;
and if it is set to -1 , it always switches to http.
FYI: you can force https or http for each Joomla menu in the menu settings Metadata > Secure : selection between 3 cases: ignore / on / off. (0 / 1 / -1)
Ok, in this case your code is correct and it will behave correctly.
from memory the JRoute of this link was removed around 3.0.11+ because changes in the J3.4.x broke it...
and on multi-linguals I always have problems with Go to cart link in the popup
You could prob do these changes in padded.php to avoid core changes -- that's where I fix my add to carts
@GJC: Hey, yes - you are right. Thanks for your answer; I want to show core functionality too, to get generally rid off this behavior. In the past I did it your way, but I'm frustrated doing this every time, upgrading the system and using the nearly the standard templates and using _no_ overrides, i.e. out of the box. Inclusive the SEO and language support.
Thank you for your respond!
Just for Information: I know about this Joomla 3.4.x broke, the problem was the testing of internal and external link; but with JRoute::_('index.php?....'), Joomla will recognize this link as internal only.
Nevertheless, from my memory, building JRoute with the whole URL and with 'http(s)://<mywebsite>/index.php...' since J 3.4.x, it indicates this as an external link and broke! Some designs didn't work any more.... (they did it due to security reasons).
First, as mentioned in other threads already, it dont need to be sefed-
Quote from: Thomas Kuschel on April 20, 2016, 11:33:14 AM
- No need to handle the language string because JRoute do this itself
if it would worked that way, I would not added it.
Quote from: Thomas Kuschel on April 20, 2016, 11:33:14 AM
- Itemid is also handled via JRoute
Should, but does not always
Quote from: Thomas Kuschel on April 20, 2016, 11:33:14 AM
- scheme (http and https) handling was not correct, when you are already on https it switches back to http if useSSL was 0 - only if useSSL was enabled, the link was created with https; this is now inside JRoute; now it does not switch from https back to http if useSLL is disabled
Right, good point. should be changed or maybe got changed already. But you can also avoid that behaviour by forcing ssl for the whole page.
Thank you, Milbo, for your respond.
QuoteBut you can also avoid that behaviour by forcing ssl for the whole page.
You should always do this, forcing
ssl for whole site! Here at LOYTEC's, we need both https and http driven server, b/c some old customer's clients support http only (hardware devices which can connect to the website and download firmware specific stuff).
I think that is the reason that we do not notice it yet. Cause most people use the "force ssl for whole site"