X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Changing design (https://forum.x-cart.com/forumdisplay.php?f=51)
-   -   Add "View All" to "Products Per Page" Dropdown (https://forum.x-cart.com/showthread.php?t=61368)

nickff 10-25-2011 08:26 AM

Add "View All" to Products Per Page Dropdown
 
Hello all,

I'm looking to add a "view all" option to customer/main/per_page.tpl in a 4.4.4 store. Try as I might, the only way I could figure to do it was to hand code the options into the dropdown, one of which is "2000" (effectively, "All"). The issue with this is that is doesn't remember the previous selection when the page refreshes:

http://future.thefutureforward.com/~clover/home.php?cat=1

This seems like a feature that should just be there, but alas it is not. If anyone has any thoughts on how to edit customer/main/per_page.tpl and include/search.php to include a "view all" option, that would be amazing!

cflsystems 10-25-2011 07:23 PM

Re: Add "View All" to "Products Per Page" Dropdown
 
These values are hard coded in include/search.php

nickff 10-26-2011 03:29 AM

Re: Add "View All" to "Products Per Page" Dropdown
 
Hey Steve,

I just noticed that. Here's where I'm guessing I need to make a change:

PHP Code:

$perPageValues = array();

        for (
$i 550 >= $i$i $i 5) {
            
$perPageValues[] = $i;
        }

        
$smarty->assign('per_page',         'Y');
        
$smarty->assign('per_page_values',  $perPageValues); 


I totally get how to change the values in the dropdown, but I'm a bit unclear as to how to add one option to the end of the dropdown with a value of, let's say, 2000 that reads in the dropdown as "View All".

Any idea on how to implement that type of a selection into this thing?

cflsystems 10-26-2011 09:06 AM

Re: Add "View All" to "Products Per Page" Dropdown
 
for ($i = 5; 50 >= $i; $i = $i + 5) {
$perPageValues[] = $i;
}

$perPageValues[2000] = 'View All';

This will only show the selection option - you still have to implement the code what will happen when this options is selected - if you have over 2000 products not all will show

nickff 10-26-2011 10:31 AM

Re: Add "View All" to "Products Per Page" Dropdown
 
Hey Steve,

Thanks for the tip.

I've got it setup like so:

PHP Code:

for ($i 50100 >= $i$i $i 50) { 
    
$perPageValues[] = $i


$perPageValues[2000] = 'View All'


Here's the result - http://future.thefutureforward.com/~clover/home.php?cat=1

Like you said, this put "View All" into both the "Value" and the "Text" of the option value. While I need it to be the "Text", I need "2000" to be the value.

I tried replacing the value with jQuery, but to no avail. Any thoughts on how to get 2000 to be the value?

cflsystems 10-26-2011 11:12 AM

Re: Add "View All" to "Products Per Page" Dropdown
 
Try with quotes for 2000

$perPageValues['2000'] = 'View All';

nickff 10-26-2011 12:18 PM

Re: Add "View All" to "Products Per Page" Dropdown
 
Hmm, tried that and it still seems to be rendering the following html:

HTML Code:


<option value="View All">View All</option>


Instead of:

HTML Code:

<option value="2000">View All</option>

Here's the current PHP:

PHP Code:

for ($i 50100 >= $i$i $i 50) { 
            
$perPageValues[] = $i
        } 

        
$perPageValues['2000'] = 'View All';

        
$smarty->assign('per_page',         'Y');
        
$smarty->assign('per_page_values',  $perPageValues); 


Thanks for all your help on this Steve. It's so appreciated.

cflsystems 10-26-2011 04:05 PM

Re: Add "View All" to "Products Per Page" Dropdown
 
Just like I had it first

for ($i = 5; 50 >= $i; $i = $i + 5) {
$perPageValues[] = $i;
}

$perPageValues[2000] = 'View All';

Then in /skin/common_files/customer/main/per_page.tpl replace


PHP Code:

{foreach from=$per_page_values item="value"}
<
option value="{$value}"{if $value eq $objects_per_pageselected="selected"{/if}>{$value}</option>
{/foreach} 


with

PHP Code:

{foreach from=$per_page_values item="value" key=k}
{if 
$k eq 2000}
<
option value="{$k}"{if $value eq $objects_per_pageselected="selected"{/if}>{$value}</option>
{else}
<
option value="{$value}"{if $value eq $objects_per_pageselected="selected"{/if}>{$value}</option>
{/if}
{/foreach} 


Then you also have to take care of $objects_per_page so it is selected if view all is selected

nickff 10-26-2011 04:25 PM

Re: Add "View All" to "Products Per Page" Dropdown
 
Pure brilliance steve. I knew there had to be a way to specify the "key", but it was eluding me.

I ended up changing the option tag to:
HTML Code:


<option value="{$k}"{if $k eq $objects_per_page} selected="selected"{/if}>{$value}</option>


And this correctly sets "view all" to selected when you select it.

http://future.thefutureforward.com/~clover/home.php?cat=8

Thanks so much steve!

tickseed 04-08-2012 12:31 PM

Re: Add "View All" to "Products Per Page" Dropdown
 
Nick, Steve,

Thanks very much for this. Just added it to 4.4.3 site.
Should be an "off the shelf" item just like X-Cart's competitors.

Regards,

David

X Cart Gold 4.4.3


All times are GMT -8. The time now is 12:19 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.