VirtueMart Forum

VirtueMart 2 + 3 + 4 => Templating & Layouts => Topic started by: Genius WebDesign on August 06, 2012, 19:56:58 PM

Title: How to add a "show as list" option in category view frontend?
Post by: Genius WebDesign on August 06, 2012, 19:56:58 PM
Hi,

I´m struggling to find out how to add a "link" in the category view for customers to click, which will load a "show as list" view of the products.

I have already coded two different layout designs, in the same default.php file based on if-rules, one being a list view and the other being a "normal" view with large pics ect.
As it is right now in administration I can manually set a category´s "Standard number of products per row" to 1, which will trigger my if-rule and make that category show with my "list view"-design. If left as "0" it will show as a "normal view".

Now, what I also want is a link that the customer can click, which will load the page in the "show as list"-view for that customer.

How is this done?



Title: Re: How to add a "show as list" option in category view frontend?
Post by: PRO on August 06, 2012, 21:33:15 PM
http://forum.virtuemart.net/index.php?topic=97132.0


or
<?php
$currenturl=JURI::current();
$modifiedurl=$currenturl.'?Grid=1';
?>

<a href="<?php echo $modifiedurl ?>">Grid View </a>

<?php if (JRequest::getVar('Grid')!=0) { ?>

Grid html/css

<?php } ?>
Title: Re: How to add a "show as list" option in category view frontend?
Post by: Genius WebDesign on August 07, 2012, 03:59:35 AM
Thanks!, I will take a closer look at this as soon as I can
Title: Re: How to add a "show as list" option in category view frontend?
Post by: mikkidee on August 29, 2012, 10:53:36 AM
Any luck with this?
I tried it but am just getting a blank screen...
Is it possible to give a bit more detail on how to implement this?
Thanks
Title: Re: How to add a "show as list" option in category view frontend?
Post by: PRO on August 29, 2012, 14:49:31 PM
Quote from: mikkidee on August 29, 2012, 10:53:36 AM
Any luck with this?
I tried it but am just getting a blank screen...
Is it possible to give a bit more detail on how to implement this?
Thanks


http://forum.virtuemart.net/index.php?topic=97132.0
Title: Re: How to add a "show as list" option in category view frontend?
Post by: mikkidee on August 30, 2012, 15:19:23 PM
Thanks for your prompt reply PRO

I went to the link you provided, read through the posts and implemented it on my development site. Everything works nicely with regards to changing the styles, but I was wondering about the alternate code you provided...

Quote from: PRO on August 06, 2012, 21:33:15 PM

or
<?php
$currenturl=JURI::current();
$modifiedurl=$currenturl.'?Grid=1';
?>

<a href="<?php echo $modifiedurl ?>">Grid View </a>

<?php if (JRequest::getVar('Grid')!=0) { ?>

Grid html/css

<?php } ?>


This code results in a blank screen when inserted in the category default.php... maybe I'm inserting it in the wrong place? This is why I asked for more detail on implementation.

What I would like to do is have the default.php for grid view and then load another page (default2.php) for list view - I really just want a flat list of the products in the current category, with product category, name, short description, and price with minimal styling - which I have done in default2.php. Is this possible using either of these methods?

Thanks again

Mike

VM 2.0.10 | J!2.5.6
Title: Re: How to add a "show as list" option in category view frontend?
Post by: PRO on August 30, 2012, 15:49:37 PM
Quote from: mikkidee on August 30, 2012, 15:19:23 PM
Thanks for your prompt reply PRO

I went to the link you provided, read through the posts and implemented it on my development site. Everything works nicely with regards to changing the styles, but I was wondering about the alternate code you provided...

Quote from: PRO on August 06, 2012, 21:33:15 PM

or
<?php
$currenturl=JURI::current();
$modifiedurl=$currenturl."&Grid=True";
?>

<a href="<?php echo $modifiedurl ?>"><Grid View </a>

<?php if (!empty( JRequest::getVar('Grid')) { ?>

Grid html/css

<?php } ?>


This code results in a blank screen when inserted in the category default.php... maybe I'm inserting it in the wrong place? This is why I asked for more detail on implementation.

What I would like to do is have the default.php for grid view and then load another page (default2.php) for list view - I really just want a flat list of the products in the current category, with product category, name, short description, and price with minimal styling - which I have done in default2.php. Is this possible using either of these methods?

Thanks again

Mike

VM 2.0.10 | J!2.5.6


<?php
$currenturl=JURI::current();
$modifiedurl=$currenturl.'?Grid=1';
?>

<a href="<?php echo $modifiedurl ?>">Grid View </a>

<?php if (JRequest::getVar('Grid')!=0) { ?>

Grid html/css

<?php } ?>
Title: Re: How to add a "show as list" option in category view frontend?
Post by: mikkidee on August 31, 2012, 13:58:01 PM
Thanks PRO

Works like a charm! Simply added another link and if statement, one for grid view and one for list view, and with a bit of styling I got exactly what I needed. This method is MUCH easier than the other jQuery method...