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

Smarty {break} and {continue} Tags

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions > Changing design
 
Thread Tools Search this Thread
  #1  
Old 11-14-2013, 06:47 AM
 
PhilJ PhilJ is offline
 

X-Guru
  
Join Date: Nov 2002
Posts: 4,094
 

Default Smarty {break} and {continue} Tags

Thought I'd share this...

Smarty {break} & {continue} tags are not available in Smarty v2, but are in Smarty v3.

They are handy, for example, if you want to truncate {foreach} or {section} items after x items / iterations.

Code:
{foreach from=$foo item=x name=whatever} {if $smarty.foreach.whatever.index == 3} {break} {/if} ... {/foreach}

(stops on third item)

Upload the attached two PHP files to /include/templater/plugins and you can use {break} and {continue}

Might assist some of you out there
Attached Files
File Type: php compiler.break.php (82 Bytes, 196 views)
File Type: php compiler.continue.php (88 Bytes, 182 views)
__________________
xcartmods.co.uk
Reply With Quote

The following 6 users thank PhilJ for this useful post:
ADDISON (11-14-2013), Ben G (09-08-2014), cherie (11-18-2013), DanielleHoyt (02-13-2015), qualiteam (11-17-2013), totaltec (11-14-2013)
  #2  
Old 11-17-2013, 11:47 PM
  qualiteam's Avatar 
qualiteam qualiteam is offline
 

X-Guru
  
Join Date: Dec 2010
Posts: 6,373
 

Default Re: Smarty {break} and {continue} Tags

Phil, thanks for sharing this!

I've moved all other messages on switching XC4 to Smarty 3 into a separate thread:
http://forum.x-cart.com/showthread.php?p=366487
__________________
Alex Solovev,
Qualiteam

---

User manual Video tutorials X-Cart FAQ

You are welcome to press "Thanks" button
if you find this post useful

Click here to learn how to apply patches

X-Cart Extensions
Reply With Quote
  #3  
Old 09-08-2014, 06:13 PM
 
Ben G Ben G is offline
 

Advanced Member
  
Join Date: Nov 2006
Posts: 100
 

Default Re: Smarty {break} and {continue} Tags

Thanks Phil!

New functionality worked a treat in this mod for wholesale prices in v4.6.4
http://forum.x-cart.com/showthread.php?p=377050#post377050

I bet there'll be some long scripts in the rest of the standard code that the {break} tag can be used in larger stores to help improve site speed.
__________________
Ben
X-Cart 4.6.6 Gold Plus - lots of modules
X-Cart 4.7.9 Gold Plus - lots of modules
Reply With Quote

The following user thanks Ben G for this useful post:
PhilJ (09-08-2014)
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 07:51 AM.

   

 
X-Cart forums © 2001-2020