[PHPTAL] MPTT to recursive macro
Hi Guys, I have been experimenting with the Modified Pre-Order Tree Traversal Pattern, my test case code is returning the results as expected however I am having trouble with the metal macros to present it. The example I am using has 3 levels (but is potentially unlimited depth due to the MPTT pattern) and I am trying to port the example from the FAQ around it, here is an array representation of the returned database object: Array ( [0] = Array ( [CategoryID] = 1 [ParentID] = 0 [CategoryName] = Default Parent [lt] = 1 [rt] = 14 [tree_depth] = 1 ) [1] = Array ( [CategoryID] = 8 [ParentID] = 1 [CategoryName] = SysAdmin [lt] = 2 [rt] = 7 [tree_depth] = 2 ) [2] = Array ( [CategoryID] = 2 [ParentID] = 8 [CategoryName] = Linux [lt] = 3 [rt] = 4 [tree_depth] = 3 ) [3] = Array ( [CategoryID] = 3 [ParentID] = 8 [CategoryName] = Windows [lt] = 5 [rt] = 6 [tree_depth] = 3 ) [4] = Array ( [CategoryID] = 5 [ParentID] = 1 [CategoryName] = Code [lt] = 8 [rt] = 13 [tree_depth] = 2 ) [5] = Array ( [CategoryID] = 6 [ParentID] = 5 [CategoryName] = PHP [lt] = 9 [rt] = 10 [tree_depth] = 3 ) [6] = Array ( [CategoryID] = 7 [ParentID] = 5 [CategoryName] = Perl [lt] = 11 [rt] = 12 [tree_depth] = 3 ) ) The example which best sums up what I am trying to achieve with the resultset is: ul metal:define-macro=output_list tal:condition=list li tal:repeat=list_item list ${list_item/CategoryName} tal:block tal:define=list list_item/sublist metal:use-macro=output_list / /li /ul tal:block metal:use-macro=output_list / Obviously there is no sublist in the resultset so the example above is useless for this purpose, I have spent a few hours experimenting with php operator conditions trying to work around the lack of dimensions in the array but as yet have had nothing work, so I was wondering if anyone with a better idea of TAL can throw me some pointers of how I should approach this. Thanks in advance. Nick ___ PHPTAL mailing list PHPTAL@lists.motion-twin.com http://lists.motion-twin.com/mailman/listinfo/phptal
Re: [PHPTAL] MPTT to recursive macro
On 22-06-2009 at 12:26:34 Nick Pack n...@carbidefinger.net wrote: I have been experimenting with the Modified Pre-Order Tree Traversal Pattern, my test case code is returning the results as expected however I am having trouble with the metal macros to present it. I think the easiest way is to write PHP function that converts this dataset into recursive structure. -- regards, Kornel ___ PHPTAL mailing list PHPTAL@lists.motion-twin.com http://lists.motion-twin.com/mailman/listinfo/phptal
Re: [PHPTAL] MPTT to recursive macro
Thanks Kornel, that's the conclusion I came to, thought it was worth asking though! Regards, Nick From: Kornel Lesiński kor...@aardvarkmedia.co.uk Organization: Aardvark Media Limited Reply-To: Template Attribute Language for PHP phptal@lists.motion-twin.com Date: Mon, 22 Jun 2009 12:40:57 +0100 To: Template Attribute Language for PHP phptal@lists.motion-twin.com Subject: Re: [PHPTAL] MPTT to recursive macro On 22-06-2009 at 12:26:34 Nick Pack n...@carbidefinger.net wrote: I have been experimenting with the Modified Pre-Order Tree Traversal Pattern, my test case code is returning the results as expected however I am having trouble with the metal macros to present it. I think the easiest way is to write PHP function that converts this dataset into recursive structure. -- regards, Kornel ___ PHPTAL mailing list PHPTAL@lists.motion-twin.com http://lists.motion-twin.com/mailman/listinfo/phptal ___ PHPTAL mailing list PHPTAL@lists.motion-twin.com http://lists.motion-twin.com/mailman/listinfo/phptal