News:

Looking for documentation? Take a look on our wiki

Main Menu

JRequest::getVar('view') returns 'Frontpage' on VM pages and URL problems

Started by unleash.it, December 28, 2007, 05:36:15 AM

Previous topic - Next topic

martin

Your a genious Pollar, really saved my day. Those this file get overridden often when joomla updates its core files?

Thanks

cclay

Just want to add my thanks to pollar for his fix. It worked perfectly...  :) 

I don't understand why this would still be an issue with Virtuemart after all this time.  :o  Hopefully a fix can be built into future versions.

Cheers,
Chris

dontflinch

Quote from: vannquish on September 20, 2010, 17:58:12 PM
Quote from: pollar on March 06, 2009, 02:09:56 AM
Hello,

This problem is mostly on VM's side. Joomla 1.5 has new way of resolving Itemid and option values. It uses JURI class to parse query string. VM passes 'index.php' instead of 'index.php?option=com_virtuemart&Itemid=<some id>' to JURI parser. So joomla just can't resolve correct option and Itemid values and uses default ('frontpage' with Itemid=1).

How to fix it? There are two ways. The first one is fixing all 'incorrect' VM's forms by changing tiny 'action="index.php"' to correct URIs with option and Itemid arguments. This solution is already provided by johk.

The second way to alter joomla code a little bit to support Itemid and option values from $_REQUEST. So here is my solution.

1. Find file named 'libraries/joomla/application/application.php'

2. Find these 2 lines (they are located somewhere around line #191):

// get the full request URI
$uri = clone(JURI::getInstance());


3. Just after these lines add this code:

// VM uri fix
if (!$uri->getVar('Itemid') && isset($_REQUEST['Itemid']) || !$uri->getVar('option') && isset($_REQUEST['option'])) {
if (!$uri->getVar('Itemid') && isset($_REQUEST['Itemid'])) {
$uri->_query = ($uri->_query ? '&' : '').'Itemid='.(int)$_REQUEST['Itemid'];
}
if (!$uri->getVar('option') && isset($_REQUEST['option'])) {
$uri->_query = ($uri->_query ? '&' : '').'option='.$_REQUEST['option'];
}
parse_str($uri->_query, $uri->_vars);
}
// end VM uri fix


The final result must be:

// get the full request URI
$uri = clone(JURI::getInstance());

// VM uri fix
if (!$uri->getVar('Itemid') && isset($_REQUEST['Itemid']) || !$uri->getVar('option') && isset($_REQUEST['option'])) {
if (!$uri->getVar('Itemid') && isset($_REQUEST['Itemid'])) {
$uri->_query = ($uri->_query ? '&' : '').'Itemid='.(int)$_REQUEST['Itemid'];
}
if (!$uri->getVar('option') && isset($_REQUEST['option'])) {
$uri->_query = ($uri->_query ? '&' : '').'option='.$_REQUEST['option'];
}
parse_str($uri->_query, $uri->_vars);
}
// end VM uri fix


That's all. I haven't tested it alot but seems it is working for me.


fixed! thanks

ditto, thanks from me too!

David Richmond

BIG THANKS!!

searched forums and tried hacking action_urls for 2 hours!

You saved my bacon!

David

adeelsikander

I was stuck on this problem since last two days it really help full for me