Displaying templated search results
Posted: Mon Dec 26, 2005 6:07 pm
Hello,
I have a search system and I'm using smarty to template them and make them look all nice and idiot-proof. The search results have to come up as pictures with some text underneath. Here's the problem: I have three tables that I'm working with. One for the whole page (I don't care about that one), One for each row, and one for each result. Each row will have three results on it. The problem is that I have no idea how to do this in smarty because smarty has no humane loop function. In the past (when I didn't have to break results down in groups of 3), I'd just dump all the results into a 2D array, something like this:
I'd pass this array to smarty, and loop using the section command, something like this:
This is of course an oversimplified example, but it goes till all the results are taken care of. The question is, how do I split them into groups of three?
Thanks!
I have a search system and I'm using smarty to template them and make them look all nice and idiot-proof. The search results have to come up as pictures with some text underneath. Here's the problem: I have three tables that I'm working with. One for the whole page (I don't care about that one), One for each row, and one for each result. Each row will have three results on it. The problem is that I have no idea how to do this in smarty because smarty has no humane loop function. In the past (when I didn't have to break results down in groups of 3), I'd just dump all the results into a 2D array, something like this:
Code: Select all
searchresults Array=>
[0]=>Array
['username']=>evilmonkey
['picture'] => evil.jpg
[1]=>Array
['username']=>joeblow
['picture']=>joeblow.jpgCode: Select all
{section name=results loop=$results}
{$results[results].username}//gives evilmonkey on first run, joeblow on the second
{$results[results].picture}Thanks!