[PHPTAL] access previous / next item in array?
I'm doing a div tal:repeat=item items Previous id: ??? Current id: ${item/id} Next id: ??? /div Is there any way to add a callback function that will be called on each repeat, so I could easily put the next and previous id ? I could loop through the array in PHP, before assigning to PHPTal object, and set them. But that would mean looping through the array twice (once before, once for output)... ___ PHPTAL mailing list PHPTAL@lists.motion-twin.com http://lists.motion-twin.com/mailman/listinfo/phptal
Re: [PHPTAL] access previous / next item in array?
On 18-09-2009 at 10:50:30 GRolf ger...@pictureparking.com wrote: I'm doing a div tal:repeat=item items Previous id: ??? Current id: ${item/id} Next id: ??? /div Is there any way to add a callback function that will be called on each repeat, so I could easily put the next and previous id ? I could loop through the array in PHP, before assigning to PHPTal object, and set them. But that would mean looping through the array twice (once before, once for output)... If array is numerically indexed, then this will work: tal:define=prev items/${php:repeat.item.index - 1}/id | nothing; next items/${php:repeat.item.index + 1}/id | nothing RepeatController reads one item ahead and could store previous item, so if you're willing to change PHPTAL's code, it's possible to easily add something like repeat.item.next/repeat.item.prev. -- regards, Kornel ___ PHPTAL mailing list PHPTAL@lists.motion-twin.com http://lists.motion-twin.com/mailman/listinfo/phptal
[PHPTAL] ajax and phptal
Hi I am working on ajax php website. Ajax makes using phptal more complicated. My approach is to divide single page to several php files and every time at single page i create new object of $tpl. It means that I have to use several $tpl-execute() at the first page load. I think it is not optimal. My question is whether there is most efective way to use phptal and ajax? Greetings ___ PHPTAL mailing list PHPTAL@lists.motion-twin.com http://lists.motion-twin.com/mailman/listinfo/phptal
Re: [PHPTAL] ajax and phptal
On 18.09.2009, at 23:34, hosema...@poczta.onet.pl wrote: Hi I am working on ajax php website. Ajax makes using phptal more complicated. My approach is to divide single page to several php files and every time at single page i create new object of $tpl. It means that I have to use several $tpl-execute() at the first page load. I think it is not optimal. My question is whether there is most efective way to use phptal and ajax? page.xhtml: body stuff tal:block metal:use-macro=widget.xhtml/show_widget / stuff /body widget.xhtml: div metal:define-macro=show_widget ajax me! /div tal:block metal:use-macro=show_widget / This will let you either execute page.xhtml with all stuff in it, or execute widget.xhtml and just output that single fragment. You can use variables in use-macro (e.g. show_${name}), so you're not limited to one thing per file. -- regards, Kornel ___ PHPTAL mailing list PHPTAL@lists.motion-twin.com http://lists.motion-twin.com/mailman/listinfo/phptal