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

<< < (16/17) > >>

vannquish:
Quote from: pollar on March 05, 2009, 19:09:56 PM

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):

Code:

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

3. Just after these lines add this code:

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:

Code:

// 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

Lee Wilson:
A thumbs up for this. I still can't quite believe that this is an issue after reading threads of up to 2 years old with no fix.... finally stumbled on this. Thank you

flora01:
thanks pollar :D
you just made my day :D

I'll append this link to the list of the
"joomla/virtuemart posts that made my day" in my signature

again, a million thanks :)

PS, i'm on  VM1.5 joomla 1.5.21
no probs so far :)

Brick Stone:
I was not doing well with this... not after metamodguy posted his snippet.  Then it dawned on me...

All these codes do fix everything... but then if you apply his to my situation

Quote

the pop confirmation dialogue pointed to some different cart.  I made a menu link to this url.  but this version of the cart still malfunctioned.

Well here is what happened.

All the fixes tell Virtuemart to get an actual Itemid or to at least try...

But then Metamod's snippet told the whole system to reference and redirect to Itemid=1  and that was still not working... one cart button brought up one page... and the tiny cart button in the pop up dialogue... pointed to another verion of the main storefront....  ODD!!! and this one was still broken


so I changed metatmod's code to make it a different number... and all is well

Code:

function getShopItemid() {

if( empty( $_REQUEST['shopItemid'] )) {
$db = new ps_DB;
$db->query( "SELECT id FROM #__menu WHERE link='index.php?option=com_virtuemart' AND published=1");
$ids = $db->loadResultArray();
if ( !is_array($ids) or count($ids) == 0 ) {
$_REQUEST['shopItemid'] = 18;
} else if ( array_search( $_REQUEST['Itemid'], $ids ) !== false ) {
$_REQUEST['shopItemid'] = $_REQUEST['Itemid'];
} else {
$_REQUEST['shopItemid'] = $ids[0];
}
}

return intval($_REQUEST['shopItemid']);

}


Yeah so far so good. Thanks for everyone's help on this!

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

Thanks

Navigation

[0] Message Index

[#] Next page

[*] Previous page