Re: Adjacency List -> Hierarchy List

Jared,

I can't quite get my head around what you're doing here, but... I would be interested in your comments comparing the pros and cons of your method to the method found here (under "Menu Tree")http://tomhenry.us/tbs3/

Thanks for any insights you can contribute,
TomH

By: Jared Eckersley

Date: 2010-04-18

Time: 02:32

Re: Adjacency List -> Hierarchy List

Hi Tom,

Let me start with a code fix:

$pointers[$row[0]]['loc'] = $row[2];

Should read:

$pointers[$row[1]]['loc'] = $row[2];

Also, let me start by saying that I can not take credit for this solution. This is based on the work done by JD Bartlett.

This just makes sure that the array element is set. The reason that this is important is that a parent item could be added to the DB after a child element - or for what ever reason - you change the sort order of the sql.
The array indice 'loc' is just a means to be able to use the label in the template.

The line that sets the $data var is pointing to the top level indice of $pointer. Because this is being passed by reference, the value is not a constant. As $pointer grows in the line above, $data is also growing. The line above that is setting $pointer is doing the same thing. The child level of pointer is being set to the reference of the parent level.

I hope I was able to explain this well enough.

Since you have a test suit setup, maybe you could run some comparisons and let us know the results.

- Jared

New message

Name:

Email:

ignore this line

Email:

-> No email accessible on Web pages.

Send replies notifications by email

Readers can contact you by Anti-Spam System (*)

Subject:

Message:

Special part in message: enter text between [code] and [/code] tags.

(*) Anti-Spam System: A reader can ask for 3 emails a day, no more ; and the reader must have a valid email to ask for emails.