Author Topic: Problems with template in Virtuemart  (Read 5796 times)

PRO

  • Global Moderator
  • Super Hero
  • *
  • Posts: 10328
  • VirtueMart Version: 3+
Re: Problems with template in Virtuemart
« Reply #15 on: September 15, 2009, 14:45:58 pm »
Try this


Create a menu item to a hidden menu

and then use the URL option set to  www.mysite.com/index.php

And then set the assigned template


THIS is assuming your homepage is without the index.php

I dont know if this will work, but you can try


J3.9+ VM 3.4.2
Slowest Page Speed Score (88) (Category)
Fastest Page Speed Score (94-96) (productdetails)

TomD

  • Beginner
  • *
  • Posts: 18
Re: Problems with template in Virtuemart
« Reply #16 on: September 15, 2009, 22:37:38 pm »
i tried.. unfortunately it doesnt help  :(

TomD

  • Beginner
  • *
  • Posts: 18
Re: Problems with template in Virtuemart
« Reply #17 on: September 16, 2009, 22:25:19 pm »
IT HELPS

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.

sfuery

  • Beginner
  • *
  • Posts: 1
Re: Problems with template in Virtuemart
« Reply #18 on: October 11, 2009, 13:06:54 pm »
Thanks for the code TomD!

I was watching this thread with interest as I have the same problem with a site I'm working onhttp://www.treehousesecrets.com. I have two templates, one for the home page only, and one for the inner pages. VM ran OK until the 'Checkout', and then it reverted to the home page template.

I inserted your code on my MAMP-based test server, and it appears to resolve the problem. I'll do some more testing, and then I'll copy it up to the IIS-based production server. I'll post back if I strike any related issues.

Steve.

ppp666

  • Beginner
  • *
  • Posts: 1
Re: Problems with template in Virtuemart
« Reply #19 on: October 12, 2009, 11:45:02 am »
HUGE THANK YOU!

TomD you are my hero!
This works as a charm - been looking everywhere to solve my blank page when checking out in VM. (Using JA - Dravity theme)
 :D

metamodguy

  • 3rd party VirtueMart Developer
  • Beginner
  • *
  • Posts: 49
    • MetaMod and MetaTemplate for Joomla
Re: Problems with template in Virtuemart
« Reply #20 on: February 09, 2010, 19:38:57 pm »
Just for the record, I've built-in a fix with a very similar approach, to the free MetaTemplate extension (http://extensions.joomla.org/extensions/style-a-design/templating/11172).

The fix is activated by default when you install MetaTemplate, and if for any reason you want to deactivate the fix it can be turned off the the MetaTemplate global preferences.

The advantage of having the fix in an extension like this is that it does not require any changes to core Joomla or VM files (so it won't break when you upgrade), and it can be turned on/off or removed easily.

Hope it helps,
Stephen
Regards,
Stephen Brandon
MetaMod and MetaTemplate author