Author Topic: JRequest::getVar('view') returns 'Frontpage' on VM pages and URL problems  (Read 140832 times)

helenbn

  • Beginner
  • *
  • Posts: 40
    • Pretty Good Designs | Hey, that's pretty good!
any fix for this yet? I can't enable my cart the way it is acting.
I use Virtue Mart 1.1.3 & Joomla 1.5.10

Schafir

  • Beginner
  • *
  • Posts: 20
Unfortunately, I don't think that anyone associated with VM development really monitors these forums.  I have posted a few questions over the last year with minimal, if any help or response. 

Either the VM developers are very small in number, or their concerned with other matters.  VM is not a plug and play extension and requires programming knowledge that many don't have. 

Open-source is a double-edged sword for mission critical applications like Virtuemart.  Low cost, but only voluntary support. It may be time to go somewhere else and pay for the solution, and get support for it.


jenkinhill

  • UK Web Developer & Consultant
  • Global Moderator
  • Super Hero
  • *
  • Posts: 26993
  • Always on vacation
    • Jenkin Hill Internet
Joomla 1.5 template switching is flawed. The solution is to use the default Joomla template for Virtuemart pages and assign the front page template to home. Works OK for me.
Kelvyn

Jenkin Hill Internet,
Lowestoft, Suffolk, UK

Unsolicited PMs/emails will be ignored.

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

Currently using VM 3.4.0.9935 on Joomla 3.8.12 PHP 7.0.31
Testing VM 3.4.0.9941 on Joomla 3.8.12

helenbn

  • Beginner
  • *
  • Posts: 40
    • Pretty Good Designs | Hey, that's pretty good!
jenkinhill, thank you for your post but I am not sure I understand. My default template is for everything, including VM, BUT my frontpage, that that one is the assigned one.
I use Virtue Mart 1.1.3 & Joomla 1.5.10

jenkinhill

  • UK Web Developer & Consultant
  • Global Moderator
  • Super Hero
  • *
  • Posts: 26993
  • Always on vacation
    • Jenkin Hill Internet
helenbn - it worked for me but maybe the different templates I used don't have issues? Have not tried it again as I only use one template for my sites.
Kelvyn

Jenkin Hill Internet,
Lowestoft, Suffolk, UK

Unsolicited PMs/emails will be ignored.

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

Currently using VM 3.4.0.9935 on Joomla 3.8.12 PHP 7.0.31
Testing VM 3.4.0.9941 on Joomla 3.8.12

helenbn

  • Beginner
  • *
  • Posts: 40
    • Pretty Good Designs | Hey, that's pretty good!
so, what's the scuttle butt on Joomla getting this template assigning issue resolved?
I use Virtue Mart 1.1.3 & Joomla 1.5.10

unleash.it

  • Jr. Member
  • **
  • Posts: 150
Soeren or Gregdev, can we get any help with this? Can you confirm that the problem is on Joomla's end?

By the way to those who didn't understand my posts earlier. If you assign templates in the admin, every time you (or your client) adds a new page to the site, you'll have to also go to the template manager and manually assign the page to the right template. Not a big problem for a small site that you maintain, but its a drawback if you have clients adding pages.

While my "hack" won't automate the process, it should allow you to have multiple templates now if you need them. Since my previous posts were maybe a bit fuzzy... and I'm about to do this thing again so it's a refresher for me... here goes again. It's not hard, but it will take some basic Joomla template/HTML/PHP knowhow.

STEP 1: In the admin, publish a module to an unused module position like user9. Assign it to whatever pages you want to theme differently. This module doesn't have to actually appear on the front end unless you want it to. One module allows for two "templates". If you need a 3rd look, publish a 2nd module, etc. Important: Make sure you publish each module to a position not occupied by any other module.

STEP 2: Use php If statements in your template to query for the module(s). If the module is published, you are on the page or one of the pages that you assigned the module to.

Something like this could go in the <head>:

Code: [Select]
<php
   $mytpl=""
   if ($this->countModules('user9')) {$mytpl='template1';} //change user9 to the module position you assigned the module
?>

This checks to see if your module is published. If it is, that means we are on a page(s) that you published it to. Next, wherever you want to vary the template, throughout your html you'd do something like:

Code: [Select]
<?php if ($mytpl=="template1") { ?>
<!-- your html/modules for template1 -->
<?php } else {?>
   <!-- your html/modules for the alternate look -->
<?php } }?>

This code is set up for two different templates but you can modify it pretty easily to accommodate more. I've tested it in a couple of ways and it worked for me, but it may or may not distinguish the store properly. You might try assigning a module to all pages NOT the store and allowing the store to be the default.

Using this method, you would be doing your template switching using modules which is still manual. If there were only a variable within the Joomla framework to tell what category/component/frontpage we are on (and can be counted on), the process could be automated so no hack like this would be needed. Using the Joomla View DOES work when you're not using VM, which seems a bit strange (to me) that it's a Joomla problem...


breezy

  • Beginner
  • *
  • Posts: 1
I searched the joomla forum for this issue and I only found 1 post and it remains unresolved. http://forum.joomla.org/viewtopic.php?f=467&t=287369

Has anyone figured this out?  I am not strong in php or any scripting language for that matter but it seems that if there is a way to pass through the url the option and checkout step, the correct template would display.  Example, if you are on step 3, payment method, and you click the link under the second cart (to link back to step 2, shipping methods) the proper template appears.  To a non-programmer like myself it seems possible to pass the '&option=com_virtuemart&checkout_stage=' through the url and still hide all the private data.  Can someone tell me if this is even possible??  the link would be some variant of this for step 2 - shipping methods: https://yourdomain.com/index.php?page=checkout.index&option=com_virtuemart&checkout_stage=2

payment method would be the same only with '&checkout_stage=3', etc.

I am sure this is Joomla related, but I doubt it will be resolved anytime soon, just hoping for a workaround until its resolved completely.

unleash.it: I could not get your fix to work with my joomla/VM application.

helenbn

  • Beginner
  • *
  • Posts: 40
    • Pretty Good Designs | Hey, that's pretty good!
Hi breezy, I made one change so far to my VM coding and it has fixed the correct template to load when you update the cart. I am not sure if it breaks anything else, but I know that it doesn't fix the coupon application so it probably will need to be used in other pages of code.

What I did was this:

in yoursitejoomla/administrator/components/com_virtuemart/html/basket.php

I searched for the section about half way down:

Code: [Select]
/* UPDATE CART / DELETE FROM CART */
$action_url = $mm_action_url.basename($_SERVER['PHP_SELF']);

this part 'PHP_SELF' calls for what page loads. I replaced with this:

Code: [Select]
/* UPDATE CART / DELETE FROM CART */
$action_url = $mm_action_url.basename($_SERVER['REQUEST_URI']);

Notice the 'REQUEST_URI'.See this site for a brief but layman's explaination:

http://php.about.com/od/learnphp/qt/_SERVER_PHP.htm

Now I imagine that I will have to follow this through the checkout into different pages to make it flow. I am not that far along in the setup, but if you get to that, please post whatever other pages you find that are in need of this change.
I use Virtue Mart 1.1.3 & Joomla 1.5.10

jenkinhill

  • UK Web Developer & Consultant
  • Global Moderator
  • Super Hero
  • *
  • Posts: 26993
  • Always on vacation
    • Jenkin Hill Internet
helenbd, that is a neat workaround. I am advised it will only work on Apache servers, though.

There is a code snippet seen elsewere that may enable REQUEST_URI to be used on Windows servers, but this would only be useful to those who use Joomla template switching.

http://api.drupal.org/?q=api/function/request_uri/HEAD
Kelvyn

Jenkin Hill Internet,
Lowestoft, Suffolk, UK

Unsolicited PMs/emails will be ignored.

Please mention your VirtueMart, Joomla and PHP versions when asking a question in this forum

Currently using VM 3.4.0.9935 on Joomla 3.8.12 PHP 7.0.31
Testing VM 3.4.0.9941 on Joomla 3.8.12

johnwasneverhere

  • Beginner
  • *
  • Posts: 36
i have made some of this work by using this in your frontpage template index.php
Code: [Select]
<?php if (JRequest::getVar('option') == 'com_virtuemart' ){?>

try like this....



Code: [Select]
<?php if (JRequest::getVar('option') == 'com_virtuemart' ){?>

  <div  id="main"><jdoc:include type="component" style="xhtml"/>



<?php else {?>


<div  id="bottom-2"><jdoc:include type="modules" name="bottom2_vj22" style="xhtml" />


<?php }?>

you could leave the div after the "else" blank to just have the component included... this will work if your frontpage template is not completely different from you main template and just requires a few different elements... like a header image... for ex ample...

Code: [Select]
<?php if (JRequest::getVar('option') == 'com_virtuemart' ){?>

<img src="<?php echo $this->baseurl ?>/templates/<?php echo $this->template ?>/images/header2.jpg" alt="header" width="910" height="125">

<?php else {?>

<img src="<?php echo $this->baseurl ?>/templates/<?php echo $this->template ?>/images/header.jpg" alt="header" width="910" height="346">

<?php }?>


hope this helps

unleash.it

  • Jr. Member
  • **
  • Posts: 150
Thanks jwnh... Definitely will give this a try when I have the chance. Have you tested it through checkout and in the account section? That's where 'view' conks out. Actually, if we can do this on any component, it opens up a whole world of automated templating.

On my first site, I only needed a couple variations so my code looked like yours, just do an IF statement when I needed a change. But what about the idea of just having two or more complete templates (one big PHP if statement), one after the other? Does anyone think that may cause a performance hit? I would imagine that the code only gets processed and sent to the browser when the IF is true?

tudor2004

  • Beginner
  • *
  • Posts: 4
Thanx helenbn. For the last two day i've been thinking how to fix that damn prob. i did like you said and it worked. You be blessed man!

helenbn

  • Beginner
  • *
  • Posts: 40
    • Pretty Good Designs | Hey, that's pretty good!
Ah, tudor2004. I may be blessed, but my VM sure is not. I found that there were other pages that were also loading the home page template so I gave up. Totally.... :'(

If anyone figures out which other pages need code changes and where, please post back here.
I use Virtue Mart 1.1.3 & Joomla 1.5.10

johk

  • Jr. Member
  • **
  • Posts: 107
helenbn,
Could you do a find and replace all ($_SERVER['PHP_SELF']); with ($_SERVER['REQUEST_URI']); or would that casue other problems futher down the track?
Cheers,
jonas