| ||||||||||
![]() |
Shopping cart software Solutions for online shops and malls | |||||||||
![]() |
![]() |
|
X-Cart Home | ![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
![]() |
"look ahead" in a section loop | |||
![]() |
|
|
Thread Tools | Search this Thread |
#1
|
|||||||||
|
|||||||||
![]() Not sure if this is possible with smarty but thought I would ask
I am displaying products in 3 columns sorted by manufacture. I would like to place the product manufacture name at the beginning of each "section" of manufactures ASCII excample below manufacture1--------- prod1 prod2 prod3 prod4 prod5 manufacture2--------- prod6 prod7 prod8 prod9 manufacture3--------- prod10 With lots of help from pmstudios the manufacture info for each product is displaying and the products are sorted in the correct order My thought was to do something like if product manufactureID is not equal to product_next manufactureID output manufacture name My question is in {section name=product loop=$products} can I "look ahead" to the next product in the loop to compare to the current product's manufacturer id? Thanks!
__________________
animator for hire onthez.com ------------------------ x-cart v4.0.5 Linux _________________ |
|||||||||
#2
|
|||||||||
|
|||||||||
![]() Your best bet would be to build an associative array to loop over as it would make it alot easier to maintain and edit. You'll need to group your data into a per manufacturer basis and order by manufacturer.
Basic example of an associative array: Code:
|
|||||||||
#3
|
|||||||
|
|||||||
![]() Hey jds580s,
To do what you're describing now changes the previous stuff (actually a bit simpler). Just replace the previous code in products.php with Code:
Then in your template you'll do something like this Code:
Hope this helps....
__________________
X-Cart 4.0.5 MySQL: 3.23.58 PHP 4.3.2 |
|||||||
#4
|
|||||||||
|
|||||||||
![]() Thanks Boomer and pmstudios.
pmstudios, I actually use what you helped me with earlier in another section of the cart. I was able to solve this issue in the template (well almost, I've still got a few things to work out) but it's 90% of the way there. Code:
My original approach of looking ahead seemed way to hard, but I thought, why look ahead when I can look back?! I just set a variable towards the end of the loop that remembers what the manufacture was of the last product and if it is the same, it just skips the code.
__________________
animator for hire onthez.com ------------------------ x-cart v4.0.5 Linux _________________ |
|||||||||
![]() |
|
Thread Tools | Search this Thread |
|
|
|
|||
X-Cart forums © 2001-2020
|