News:

You may pay someone to create your store, or you visit our seminar and become a professional yourself with the silver certification

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

ProjectReady

Because I'm on J1.0 something I make the change Change ($_SERVER['PHP_SELF']) with ($_SERVER['REQUEST_URI']) like said before and everything work well (multi-template and language). The only thing where isn't working it's the the Add to cart btn in the product page. Still bring to http://www.mywebsite.com/index.php

So I change in file /product_details/includes/addtocart_from.tpl.php around lign 21 <form action="<?php echo $mm_action_url ?>index.php" for the direct URL of the cart with all the parameter. (You can find this URL by using Cart Module).

work OK for me and the Joomfish switch don't "switch" to the wrong template.

silentBob

hi,

i read that pollar used this hack to activate diferent templates for different VM categories. i patched my ps_session.php like pollar and also did that hack for the application.php (VM uri fix)

but now how can i set my templates that i installed for an categorie of VM?


perhaps someone can write an tutorial for that VM multi Template option, this would be great and post it in this forum?

backway2

thank you pollar, it worked for me too - after spending 2 days trying to work this out.
Appreciated

unleash.it

silentBob, that's not what we've been talking about here (at least as far as I've seen), but you might try metamod: http://extensions.joomla.org/extensions/access-a-security/frontend-access-control/3391

The idea would be to publish a custom HTML module with template markup only on certain virtuemart categories. Make sure to use JCE or something that doesn't strip it out...

Not the most elegant, but should work if you're not so great with PHP like me.

amorino

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.


Thanks a lot Pollar
This worked for me like a charm
Création sites web Tunisie
http://www.idealconception.com

jehanon

Quote from: rgibbs421 on April 23, 2009, 21:37:22 PM
in the ps_session.php file located in administrator/components/com_vertuemart/classes i changed the line 503

"$Itemid = "&Itemid=".$this->getShopItemid();"
to
"$Itemid = "&Itemid=1".$this->getShopItemid();"



there is nothing at line 503 but at 548 :
// If we haven't found an Itemid, use the standard VM-Itemid
$Itemid = "&Itemid=" . ($tmp_Itemid ? $tmp_Itemid : $this->getShopItemid());

I have changed for
$Itemid = "&Itemid=1" . ($tmp_Itemid ? $tmp_Itemid : $this->getShopItemid());

but I still have a blank page  when products are not found in search box

jehanon

Quote from: rgibbs421 on April 23, 2009, 21:37:22 PMchanging application.php doesnt solve it for me

index.php?page=shop.browse&option=com_virtuemart&Itemid=9  gives a blank page  when search box returns nothing

stano

A big thank you Pollar!
Saved my weekend and many further hours of searching :)

vincent79

Thank you Pollar! Great! I can now go to sleep (ok it's not too late 1:46)


chris w

this whole issue is ridiculous, i can tfind a solution that doesnt either work or stop something else working. virtuemart was working fine for me for many years and then this comes along. does this mean this problem will arise on my other virtuemart sites?

baggiesmad

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

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 :)
Live Smart, Eat Smart,
Flora Organica http://www.flora-organica.com

the Joomla/Virtuemart links that made my day
"checkout redirects to index.php"? read this: http://forum.virtuemart.net/index.php?topic=34989.msg170542#msg170542

Brick Stone

#74
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

Quotethe 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

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!