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

{section} How to end section loop early....

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 06-14-2004, 07:51 AM
 
garryhs garryhs is offline
 

Senior Member
  
Join Date: Sep 2002
Location: Australia
Posts: 159
 

Default {section} How to end section loop early....

Hi all,

I have a section that is looping through 1000's of records. When I find what I want, how do I exit the loop. ???

Any ideas ? As I cacnot seem to find anything on this.

Example:

Array is $test

{section name=test loop=$test}
{if $test[test] eq $my_parm}
then I want to exit the loop ! How ?
{/if}
{/section}

Any info would be great.
__________________
All versions of X-Cart

Been in eCommerce 10 years, Coding, PM, SEO, Social. X-Cart 11 years. IT 30+ years.

Head of Web Dev for Australia's largest eCommerce 2 years.

Attended conferences, Velocity 2009 US, CeBit 2009, MySQL 2010 US, Online Retailer 2010, Web 2.0 2011 US, MySQL 2012 US (Percona).

Specialise in High Performance, High Volume, PHP, MySQL, HTML, CSS, JAVASCRIPT, SMARTY, MEMCACHED, APACHE, LIGHTTPD, FREEBSD, LINUX.

Email your requests to xcart@gazwebtech.com
Reply With Quote
  #2  
Old 06-14-2004, 04:39 PM
  shan's Avatar 
shan shan is offline
 

X-Guru
  
Join Date: Sep 2002
Location: Birmingham, UK
Posts: 6,163
 

Default

Array is $test

Code:
{section name=test_num loop=$test} {if $test[test_num].param eq $my_parm} $test[test_num].param {/if} {/section}

That code will only print the row in the loop that matches your $my_param.

not sure if thats what your looking for.

the loop would be made up from a php file / mysql statement and the {if} statement will pick out the row you want.

If you wanted to minimise the amount of rows in the array you would need to alter the sql statement
__________________
Looking for a reliable X-cart host ?
You wont go wrong with either of these.

EWD Hosting
Hands On Hosting
Reply With Quote
  #3  
Old 06-14-2004, 10:14 PM
 
garryhs garryhs is offline
 

Senior Member
  
Join Date: Sep 2002
Location: Australia
Posts: 159
 

Default Issues with {section} processing time...

Hi,

Basically that is what I am doing.

I just want to exit the loop once I have what I want as to minimize processing time.

The way I have coded it. It works, but it is slow on large databases, just want to work out of a way of dropping out of the section once the if condition is met.

Any ideas...
__________________
All versions of X-Cart

Been in eCommerce 10 years, Coding, PM, SEO, Social. X-Cart 11 years. IT 30+ years.

Head of Web Dev for Australia's largest eCommerce 2 years.

Attended conferences, Velocity 2009 US, CeBit 2009, MySQL 2010 US, Online Retailer 2010, Web 2.0 2011 US, MySQL 2012 US (Percona).

Specialise in High Performance, High Volume, PHP, MySQL, HTML, CSS, JAVASCRIPT, SMARTY, MEMCACHED, APACHE, LIGHTTPD, FREEBSD, LINUX.

Email your requests to xcart@gazwebtech.com
Reply With Quote
  #4  
Old 06-15-2004, 03:45 AM
  TelaFirma's Avatar 
TelaFirma TelaFirma is offline
 

X-Adept
  
Join Date: Nov 2002
Location: North Carolina USA
Posts: 930
 

Default

I would suggest filtering at the PHP level, either by the WHERE clause in you DB query (preferably), or by using foreach and if/then loops in PHP.

Processing time will be MUCH shorter.
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 12:49 AM.

   

 
X-Cart forums © 2001-2020