Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

Add "View All" to "Products Per Page" Dropdown

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 10-25-2011, 08:26 AM
 
nickff nickff is offline
 

Senior Member
  
Join Date: Aug 2010
Posts: 132
 

Default 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!
__________________
nick hoag
looking forward to the future
http://thefutureforward.com
xcart versions 4.2.x, 4.3.x, 4.4.x
Reply With Quote
  #2  
Old 10-25-2011, 07:23 PM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 14,201
 

Default Re: Add "View All" to "Products Per Page" Dropdown

These values are hard coded in include/search.php
__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote
  #3  
Old 10-26-2011, 03:29 AM
 
nickff nickff is offline
 

Senior Member
  
Join Date: Aug 2010
Posts: 132
 

Default 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?
__________________
nick hoag
looking forward to the future
http://thefutureforward.com
xcart versions 4.2.x, 4.3.x, 4.4.x
Reply With Quote
  #4  
Old 10-26-2011, 09:06 AM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 14,201
 

Default 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
__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote
  #5  
Old 10-26-2011, 10:31 AM
 
nickff nickff is offline
 

Senior Member
  
Join Date: Aug 2010
Posts: 132
 

Default 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?
__________________
nick hoag
looking forward to the future
http://thefutureforward.com
xcart versions 4.2.x, 4.3.x, 4.4.x
Reply With Quote
  #6  
Old 10-26-2011, 11:12 AM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 14,201
 

Default Re: Add "View All" to "Products Per Page" Dropdown

Try with quotes for 2000

$perPageValues['2000'] = 'View All';
__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote
  #7  
Old 10-26-2011, 12:18 PM
 
nickff nickff is offline
 

Senior Member
  
Join Date: Aug 2010
Posts: 132
 

Default 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.
__________________
nick hoag
looking forward to the future
http://thefutureforward.com
xcart versions 4.2.x, 4.3.x, 4.4.x
Reply With Quote
  #8  
Old 10-26-2011, 04:05 PM
  cflsystems's Avatar 
cflsystems cflsystems is offline
 

Veteran
  
Join Date: Apr 2007
Posts: 14,201
 

Default 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
__________________
Steve Stoyanov
CFLSystems.com
Web Development
Reply With Quote

The following user thanks cflsystems for this useful post:
nickff (10-26-2011)
  #9  
Old 10-26-2011, 04:25 PM
 
nickff nickff is offline
 

Senior Member
  
Join Date: Aug 2010
Posts: 132
 

Default 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!
__________________
nick hoag
looking forward to the future
http://thefutureforward.com
xcart versions 4.2.x, 4.3.x, 4.4.x
Reply With Quote
  #10  
Old 04-08-2012, 12:31 PM
 
tickseed tickseed is offline
 

Advanced Member
  
Join Date: Apr 2011
Posts: 60
 

Default 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
__________________
Version 4.4.2
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 02:06 PM.

   

 
X-Cart forums © 2001-2020