Re: Array to HTML List

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is how we do it in Drupal -
https://api.drupal.org/api/drupal/includes%21theme.inc/function/theme_item_list/7
.

Oliver

On 31 March 2016 at 12:50, Lester Caine <lester@xxxxxxxxxxx> wrote:

> On 30/03/16 05:24, Kevin Waterson wrote:
> > I need to get an array of data (comments) into a threaded HTML list.
> >
> > Not too sure how to go about this one.
> >
> > Maybe I need to build up some sort of tree and traverse it.
> >
> > http://pastie.org/10778741
> >
> > Any ideas on the best way forward appreciated.
>
> Kevin
>
> The key here is your 'path' value and how it is generated.
> In my tree structures, this value is 'parent', where the top of the tree
> is id=0 and build down from that.
>
> Your id=1 and id=4 are top records. Traversing id=1, one has id=5 then
> id=7 & 8 and finally 7 descends to 9 and 10.
>
> You end up with a two dimensional array
>
> [1]
> [1]c[5]
> [1]c[5]c[7]
> [1]c[5]c[7]c[9]
> [1]c[5]c[7]c[10]
> [1]c[5]c[8]
> [4]
>
> Bit pushed for time at the moment, but I'm sure you can see that each
> level just re-curses down until the elements have no children. You add
> the wrapper for each parent level, and only add the comment when you hit
> the bottom.
>
> --
> Lester Caine - G8HFL
> -----------------------------
> Contact - http://lsces.co.uk/wiki/?page=contact
> L.S.Caine Electronic Services - http://lsces.co.uk
> EnquirySolve - http://enquirysolve.com/
> Model Engineers Digital Workshop - http://medw.co.uk
> Rainbow Digital Media - http://rainbowdigitalmedia.co.uk
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>

[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux