|
Posted by amygdala on 06/06/07 17:18
"amygdala" <noreply@noreply.com> schreef in bericht
news:4666e706$0$25476$9a622dc7@news.kpnplanet.nl...
>
> "Steve" <StevePBurgess@gmail.com> schreef in bericht
> news:1181135483.395148.227430@p77g2000hsh.googlegroups.com...
>>I have been studying the Adjacency List Model as a means of achieving
>> a folder structure in a project I am working on. Started with the
>> excellent article by Gijs Van Tulder
>>
>> http://www.sitepoint.com/article/hierarchical-data-database
>>
>> My database has this basic structure:
>>
>> Id
>> FolderName
>> ChildOf
>>
>> where ChildOf is the Id of the Folder that the current folder is
>> nested within.
>>
>> Although I can use this to make indented text lists - I want the
>> output to be a hierarchical HTML structured list using <ol><li>
>> structures.
>>
>> So, for example, my folders are:
>>
>> News
>> -Government Information
>> -BBC
>> -National Press
>> Books
>> LIS
>> -UKEIG
>> -NPRIE
>>
>> I want the output to be:
>>
>> <ol>
>> <li>News
>> <ol>
>> <li>Government Information</li>
>> <li>BBC></li>
>> <li>National Press</li>
>> </ol>
>> </li>
>> <li>Books</li>
>> <li>LIS
>> <ol>
>> <li>UKEIG</li>
>> <li>NPRIE</li>
>> </ol>
>> </li>
>> </ol>
>>
>> and for this to work irrespective of the number of levels in the
>> hierarchy.
>>
>> Any ideas?
>>
>
> Recursion my friend. I've done something simular recently, but a bit
> verbose; in every recursion I used an SQL query.
>
> However, yesterday I stumbled across an example that does the job far more
> efficient:
>
> http://www.tagarga.com/blok/on/061029
>
> Courtesy of newsgroup contributor gosha bine.
>
> HTH
Forget what I said, although useful, not exactly what you asked for of
course. Rik's example was more on point.
[Back to original message]
|