News:

Support the VirtueMart project and become a member

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

unleash.it

Is there a reason why the Virtuemart component sometimes returns "frontpage" as the Joomla View?

JRequest::getVar('view')

I am also getting URLs that are inconsistent. SEF is turned off, but sometimes the URL parameters disappear all the way back to the base URL. For instance when I add a product to the cart (any product), I get this url:

http://localhost/tdcoffee/index.php

Also, the Joomla "View" is returned as "frontpage" even though it isn't. But when I click on "Show Cart" in the Virtuemart module, I correctly get:

http://localhost/tdcoffee/index.php?page=shop.cart&option=com_virtuemart&Itemid=78

In this case the Joomla "view" returns NULL as it does on all the VM catalog pages. Both of these situations also happen on certain pages (but not all) during the checkout process. This poses a big problem for me as I am using PHP to put certain content on the Joomla frontpage using the "view" in an IF statement.

For instance I have my banner image that only shows on the front page:

<?php $fp=JRequest::getVar('view'); ?>

         <?php if ($fp=='frontpage') : ?>
                 <h1 class="logo"><?php echo $mainframe->getCfg('sitename');?></h1>
         <?php endif; ?>


This is working fine except in those couple of pages when everything falls apart. Is this a known problem, or should I submit a bug report? Or is this just the way it's supposed to work...?

I might also like to be able to use $_get statements to test for certain VM modes like checkout...although if anyone knows of a better way that will work with SEF turned on (when that comes available), that would be great.

Once again, many thanks. I hope you guys are taking some time off for the holidays and will get back to me when you can. Cheers!




unleash.it

Can any developers or experienced users take a minute to get back to me? This is a huge issue for the site I'm working on. To test this problem, I just did a clean Joomla 1.5 (rhuk_milkyway template) and VM installation, both latest builds. The results were the same. The url looses all parameters to become the base url at strange times:

*When you refresh or delete items from the cart (but not just by viewing cart).
*During the checkout process after the registration screen.

This situation also causes Joomla to think it is on the frontpage. Is this a temporary problem? Is there a work around?

As an alternative to JRequest::getVar('view') I've also tried:

<?php $menu = &JSite::getMenu(); ?>
<?php if ($menu->getActive() == $menu->getDefault()) { ?>
     //frontpage code...


Same thing. Both methods work fine on all other pages.


unleash.it

Ok, that at least  helps me to know that this is a known issue. I did check the tracker and didn't see it listed there. Do you want me to add it?

I hope I'm not asking the too many questions...or mentioning the obvious. I know the Virtuemart team is busy, not to mention that we just had the holidays (Happy New Year by the way!). Are you interested in my observations...someone with over 10 years HTML/CSS, knows Joomla, but somewhat beginning PHP skills?

I probably shouldn't have attempted a 1.1 site, but I'm too far along now. When I learned that VM stable was no longer supporting Joomla 1.5, I had already invested over six months learning Joomla 1.5 and was far along in designing a client's site. Basically I was forced to choose between going with the 1.1 beta or having to learn the fading Joomla 1.13. Since I didn't like the later idea much...I decided to take the gamble. I'm just going to hack my way through then update everything when it becomes stable. At this point it's all MOSTLY working great. Thanks everyone for your good work...Jason

jenkinhill

I have looked & tested this but I cannot see a real problem except for the difference between going to cart from the info popup when product is added to the cart (cart1 attached) and going to the crt from the show cart link on the minicart (cart2). This second view is also seen if a product is deleted or updated from the info popup-cart. Is this what is being reported here?

[attachment cleanup by admin]
Kelvyn
Lowestoft, Suffolk, UK

Retired from forum life November 2023

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

unleash.it

Jenkinhill, a big problem with this is that template designers right now don't have a way to use conditional statements based on Joomla views like frontpage. In your screen shots, I believe the reason the modules at the top appear is because Joomla thinks it's on the home page. If you like, take a look at my site:

http://tomanddave.web.aplus.net/

Click on Shop or Order Coffee then add something to the cart. Next try to delete or refesh something in the cart. The whole layout collapses. Notice what happens to the url. The problem also happens during the checkout stages. If you want to test that, you can use "tester" and "lemmein" for a fake shopper. Actually the first screen is ok, but all the rest have the problem.

I have several reasons for designing my site this way, not the least for ease of admin (and confusion) for my clients. For instance the top menu has a different background image for the home page than all other pages. I could have two separate menus in two separate positions and assign their modules page by page within Joomla, but I'd rather not if I can help it. I hope you guys can take a look at this. I'm sure I'm not the only one who would benefit.

unleash.it

Just in case anyone is interested, I found a workaround to this problem. It's not exactly elegant, but it's pretty simple.

First, you must have a module position that is assigned only to the home page. There can be no other modules ever assigned to this position. If this isn't ideal, you can just use an empty position, assign a dummy module to it then in the CSS style it visibility:hidden. Then you simply test for a module being published in that position in your if statement. Here's an example:

<!-- in the head -->
   <?php if $this->countModules('top')) {$fp='frontpage';} ?>

<!--  in the body -->
   <?php if ($fp!="frontpage"){echo '<div id="bluebar">';}?>

<!-- close the div -->
<?php if ($fp!="frontpage"){echo '</div>';}?>


This creates a blue side bar on all pages that aren't the homepage. In other words, without managing two templates, you can have a different template for the homepage and other pages among other things. This also can make managing the site much less work, no need to constantly update the pages you have your modules assigned to whenever you add a new page (when you have more than one theme).

Still not sure and it seems kind of weird why this works while Joomla views do not. Even though Joomla thinks it's on the frontpage on certain VM pages, this method worked for me.

karlis

Hello,
i've got the same problem.
I'm using 2 different templates for my site.
when user goes through checkout process template changes.

however on step 2 (shipping method) the template defaults to the front page template.

im using joomla 1.5 and virtuemart 1.1.0 Stable.

I don't understand the workaround explained by unleash.it.

unleash.it

If anyone reads this who understands how the Joomla framework interacts w/Virtuemart, it might help all of us who are trying to vary our templates if you can explain this. Specifically, why does JRequest::getVar('view') sometimes return 'Frontpage' on certain VM pages (certain checkout and cart pages) that are not the front page?

Karlis, the workaround I have found has not been tested with assigning different Joomla templates in the back end as it sounds like you are doing. The problems you're having might be related to my problem or something different.

Instead of using multiple "templates", I created my template changes with conditional statements in PHP. I only have two "looks". One is for the front page (based on the Joomla "view" of 'frontpage'), and the other is all other pages (i.e. not 'frontpage'). If this is all you need, you may be able to achieve what you're looking to do w/my workaround for now.


Schafir

I am having the same problem as Karlis. I use a different template for my commerce site than the rest of my pages.

My checkout process changes the template from the assigned Virtuemart template to the homepage template in step 2 of checkout.

Aravot, Do you know if this is a Virtuemart or Joomla bug? If Joomla, is someone working with Joomla folks to fix?  This is a serious issue for us.  Unleash-Its posted workaround doesn't apply in our our case as other pages in our site use the same template as the homepage.

thanks for your help.

Schafir

Unleash.it,

I tried to do as you suggested but cannot get to the dev.virtuemart.net site.  I get a "bad gateway" error when trying to go there.

Do you know if there is there another way to get to bug tracker?

thx.

Schafir

unleash.it

I'm having problems too. I decided to post the bug, but got an error message when trying to register:

HTTP Status 500 - java.lang.IllegalArgumentException: dto is needed to determine which listerens to notify

Schafir

I get the same error when trying to confirm my registration.  Very frustrating.

Schafir

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

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
Lowestoft, Suffolk, UK

Retired from forum life November 2023

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