Link List sidebar: ordering doesn't match XML

Creating and modifying plugins.
Post Reply
jdwarren
Regular
Posts: 8
Joined: Thu Oct 12, 2006 6:39 pm
Location: Nashville, TN
Contact:

Link List sidebar: ordering doesn't match XML

Post by jdwarren »

I'm wanting to use the linklist plugin for a menu on my site. However, the default functionality of it places any and all directories at the top of the menu -- not where they fall in the XML.

I'm going to try to take a look at the code over the weekend, but wanted to ping the community to see if anyone else has already modified the code.

Here's how I've structured the XML file, and how I'd like the menu to be displayed:

Code: Select all

Link 1
Link 2
Link 3
Dir 1
    Sub Link 1-1
    Sub Link 1-2
Link 4
Here's how it got displayed by default:

Code: Select all

Dir 1
    Sub Link 1-1
    Sub Link 1-2
Link 1
Link 2
Link 3
Link 4
Here's my 1st attempt at tweaking the code (before I added "Link 4" it was fine) -- this was done by simply moving the foreach that loops on the directories after the foreach for the links.

Code: Select all

Link 1
Link 2
Link 3
Link 4
Dir 1
    Sub Link 1-1
    Sub Link 1-2
I'm a developer, but live mostly in the Java and Perl worlds -- I'm slowly picking up PHP, but aren't quite sure at the present whether or not there's the ability to traverse an XML tree as it exists without first having to extract out arrays of various element types.

Basically what I'm thinking is something along the lines of:

Code: Select all

foreach elem in xml {
    if elem is link {
        display link
    } else if elem is dir {
        display dir name
        recurse into build_tree()
    }
}
I'm just not sure from looking at the code if I have the ability to obtain the type of the xml element -- or if it's possible to traverse the xml document in the manner I desire.

Any help on this would be greatly appreciated.

Modified just to add code tags around the above menu examples.
Last edited by jdwarren on Wed Nov 21, 2007 11:45 pm, edited 1 time in total.
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Link List sidebar: ordering doesn't match XML

Post by garvinhicking »

hi!

Could you provide the XML you use to feed to the plugin?

Itmight be that there's a sorting algorithm on the input converted data. I'd like to try that, but would need sample XML to try it with.

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
jdwarren
Regular
Posts: 8
Joined: Thu Oct 12, 2006 6:39 pm
Location: Nashville, TN
Contact:

Re: Link List sidebar: ordering doesn't match XML

Post by jdwarren »

Here's the XML I'm using.

I have two sites (well, one, but a prod and dev instance) running:
www.jonwarrenphotography.com (using my tweak)
dev.jonwarrenphotography.com (currently using the original code)

Code: Select all

<link name="Home" link="/index.php?/pages/aboutme.html" />
<link name="Galleries" link="http://gallery.jonwarrenphotography.com/" />
<link name="Contact Me" link="/index.php?/pages/contactform.html" />
<link name="Blog" link="/index.php?/categories/17-Blog-Posts" />
<link name="Calendar" link="/index.php?/wpages/calendar.html" />
<link name="Guestbook" link="/index.php?/pages/guestbook.html" />
<link name="Polls" link="/index.php?/pages/poll.html" />
<link name="Blog Archive" link="/index.php?/archives/" />

<dir name="Links">
    <dir name="My Other Sites">
         <link name="LinkedIn Profile" link="http://www.linkedin.com/in/jonwarren" />
         <link name="MySpace Profile" link="http://www.myspace.com/jon_d_warren" />
         <link name="One Model Place Profile" link="http://www.onemodelplace.com/member.cfm?P_ID=190067" />
    </dir>
    <dir name="My Memberships">
         <link name="Brentwood Camera Club" link="http://www.brentwoodcameraclub.org/" />
         <link name="Harpeth Bike Club" link="http://www.harpethbikeclub.org/" />
         <link name="Nashville MSU Alumni Club" link="http://www.nashvillemsualumniclub.com/" />
         <link name="Nashville Photography Club" link="http://www.nashvillephotographyclub.org/" />
    </dir>
    <dir name="Advocacy">
         <link name="NFIB - The Voice of Small Business" link="http://www.nfib.com/" />
         <link name="Tennessee 3 Feet dot org!" link="http://www.tennessee3feet.org/" />
    </dir>

    <dir name="Friends & Associates">
        <dir name="Artists">
            <link name="Erik Stell" link="http://gryffonx.deviantart.com/" />
        </dir>
        <dir name="Photographers">
            <link name="Jerry Atnip" link="http://www.ciacreative.com/" />
            <link name="Ron Box" link="http://www.outoftheboxphotography.com/" />
            <link name="Harrison McClary" link="http://www.mcclary.net/" />
            <link name="Danny Myers" link="http://www.myspace.com/studioshoots" />
            <link name="Okemos Studio of Photography" link="http://www.okemosstudio.com/" />
            <link name="Fran Scholl & Paul Pokrywka" link="http://www.fandpphotography.com/" />
            <link name="Jen Wood" link="http://www.jenwoodphotography.com/" />
        </dir>
        <dir name="Programmers">
            <link name="Jeff Bauer" link="http://serpentaddiction.blogspot.com/" />
        </dir>
        <dir name="Songwriters">
            <link name="Musiclarks - Tiffany & Laura" link="http://www.myspace.com/musiclarks" />
        </dir>
    </dir>
</dir>

<link name="Site Administration" link="/index.php?/admin" />
Jon Warren

JonWarrenPhotography.com
MyHumbleAbode.com (blog)
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Link List sidebar: ordering doesn't match XML

Post by garvinhicking »

Hi!

Hm, with version 1.14 of the plugin I cannot reproduce that. It shows the XML structure in exactly the flow of how it's meant to be.

I've sent you the URL of my testing site via PM so you can have a look. I used exactly the XML input you showed me here.

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
jdwarren
Regular
Posts: 8
Joined: Thu Oct 12, 2006 6:39 pm
Location: Nashville, TN
Contact:

Re: Link List sidebar: ordering doesn't match XML

Post by jdwarren »

Hmmm... It must have something to do with one of the options. I don't know why I didn't think to mention what settings I was using before.

In checking further, I found that the problem only presents itself when you choose the "CSS List" style.

The reason that I chose that style, is that it didn't output an unlabeled top level folder, like is showing up on the site you sent me.

Upon further investigation, I found that that top level folder only is displayed if I have "Use icons" set to yes. This raises another interesting question: Shouldn't the top level text only be output if and only if there is a value set for the "Top Level Text" -- regardless of whether icons are used or not?

Just in case some other setting of mine might be causing weirdness, here's what I was using (changes/notes in parens, new dtree-only options in italics):

Title: Menu
Top Level Text:
Enter XML directly: Yes
Links: {XML in earlier post}
Choose the output style for the linklist: CSS List (dtree)
Open All text: Open All
Close All text: Close All
Show Open and Close links: Yes (No)
Location of Open and Close links: Top
Use selection: No (Yes)
Use cookies: No (Yes)

Use lines: No
Use icons: No
Use status text: Yes (No -- in FF2 it didn't show anything in the statusbar for me)
Close same level: No

Target: _self (this is something I'd prefer being able to set for individual links -- there's a few that I'd rather be "_blank", but not all of them)
Category tree open or closed: Closed
Apply markup? No
Use plugin image directory: Yes

(thankfully I had my prod site, I'd forgotten about the few new options added when I switched to the "dtree" style when first I typed this post.

Thanks Garvin for your help -- it got me playing with the setting more which got things the way I wanted.
Last edited by jdwarren on Thu Nov 22, 2007 3:51 pm, edited 1 time in total.
Jon Warren

JonWarrenPhotography.com
MyHumbleAbode.com (blog)
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Re: Link List sidebar: ordering doesn't match XML

Post by garvinhicking »

Hi!

The dtree tool (javascript) that is used can only emit icons, if a top level structure is emitted. That's why we have that restriction.

I've never worked with the "CSS List" style, but it must have a different parsing then. Sadly the plugin is a bit complex and I'm not that well into it. Maybe Matthew Groeninger will chime in, as he maintains the plugin much better than I do :)

Best regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
d_cee
Regular
Posts: 603
Joined: Wed Jan 18, 2006 6:32 pm
Location: UK
Contact:

Post by d_cee »

Hi

I'm having the same problem with the link list - it puts my 'Home' link after any directories with links in when I use the 'CSS list' setting.

And is it possible when using the 'CSS list' setting instead of 'Dtree' to get the plugin to remember whether a directory link is open or closed when a link is clicked through to a new page?

cheers

Dave
garvinhicking
Core Developer
Posts: 30022
Joined: Tue Sep 16, 2003 9:45 pm
Location: Cologne, Germany
Contact:

Post by garvinhicking »

Hi!
I'm having the same problem with the link list - it puts my 'Home' link after any directories with links in when I use the 'CSS list' setting.
Maybe matthew can help there.
And is it possible when using the 'CSS list' setting instead of 'Dtree' to get the plugin to remember whether a directory link is open or closed when a link is clicked through to a new page?
No, this is technically not possible. It requires javascript to do that.

Regards,
Garvin
# Garvin Hicking (s9y Developer)
# Did I help you? Consider making me happy: http://wishes.garv.in/
# or use my PayPal account "paypal {at} supergarv (dot) de"
# My "other" hobby: http://flickr.garv.in/
Post Reply