The {iterate} function usually works on DAOResultFactory objects, which are backed by database result sets. These can only be used once, and then they’re automatically closed. If you need to go through it again, I’d suggest converting the iterator object into an array, using the toArray function, on the PHP side.
Regards,
Alec Smecher
Public Knowledge Project Team
thanks for the regular prompt replies.
please not to sound lazy or anything, I’d be grateful if you gave more pointers as to how to go about doing this.
I opened “DAOResultFactory.inc.php”, “JournalDAO.inc.php”, “ItemIterator.inc.php”, but couldn’t really wrap my head around what was going on.
I apologise in advance if it’s not allowed to ask a question in someone else’s post. It’s just that I’m facing the same road block on my project. I am working on a similar presentation, where I need to implement the iterate statement twice on a page.
I’m ok, but not really very good with php, so I don’t know how to implement the suggestions you’ve made in the comments above. Could someone please give the exact code to convert the iterator object to an array?
Then you’ll have to convert {iterate} calls to {foreach} instead (note a few small but important details in usage, such as from=$someArray rather than from=someIterator (missing $ in the iterator case).
Regards,
Alec Smecher
Public Knowledge Project Team
my final solution before now was a little jquery hacking. I used the iterate statement once, then used .after statement to move the html elements to where I wanted them in the page. (I’m not proud of this)
that was very untidy.
thanks to @asmecher and @ctgraham for joining the pieces together, now I’m doing the right thing.
The codes @asmecher suggested, work 100%. It’s been tested by me.