dropdown plugin

stefan am 18. April 2006 um 12:52 Uhr
[UPDATE: This Version of the plug-in is no longer supported. You may want to try my other dropdown plugin that works with css and doesn't need javascript.]

Ich habe gerade mein erstes Plugin für Wordpress geschrieben. Es erstellt aus statischen Seiten und Unterseiten bei wordpress ein Dropdown-Menü. Nichts allzu kompliziertes aber, wie ich finde, ganz nett. Wahrscheinlich könnte man das ganze noch kürzen und sonstwie verbessern, aber mein php reicht dafür leider dann doch nicht aus. Alles weitere in Englisch.

This small plugin (Download) turns your static pages and subpages into a drop down menu. it doesn't interfere with the sidebar and leaves the display of the pages in the sidebar intact.
I'm not really familiar with php or javascipt, so this code probably isn't poetry really, but it worked for me.

Any questions, feedback, critique or suggestions for improvements are very welcome.

It is based on functions of the templates-functions-post.php-file in your wp-includes-folder, which I changed a little and on a javascript-file by dynamicdrive (www.dynamicdrive.com...).

Basically the plugin creates some javascript and css in your header, so that your pages and their children are automatically turned into a drop down menu. The menu is highly customizable via an added options-page in the admin panel.

Attention: 'STS Drop down menu' at the moment works only for two layers of pages! So, if you have not only parent and children pages but also grand children pages etc., the menu probably won't work.

Installation:

1. Download the plugin. (Download)
2. Copy the file sts-dropdown-plugin.php into your plugin-folder.
3. Activate the plugin in the admin panel.
4. Copy the line

  1. <?php sts_output_pages('exclude=' . get_option('sts_drop_exclude') . '&sort_column=menu_order&title_li=' ); ?>


and paste it wherever you want the drop down menu to appear. (I placed it in kubrick's theme in the header after id="headerimg" and that is what the default-css refers to, but you can put it wherever you like. If you choose to put it into a different place, you may have to adjust the css within the plugin though.) The 'exclude='-command works for the top pages as well. Just add the pages you don't want to be displayed on your site to the according field in the options panel in the admin panel. The same goes for the subpages.

5. In the admin-panel under 'Options' you find a tab 'STS DropDownMenu'. There you'll find different variables you can change as you wish.

The drop down pages can be sorted after their Page Order. In order to order the pages via that you will have to give them a page order number in the admin-panel under the according page under 'Page Order'. If you don't they will be displayed in the order of their page_id.

If you want to set the width for the drop down menu for every header individually, you may have to copy the corresponding source text in your website, paste it where
  1. &lt;?php sts_output_pages('sort_column=menu_order&title_li=' ); ?>
was and adjust the width as described on www.dynamicdrive.com....

That's it. I hope you enjoy it or find it useful.

still to do:
1. Make it work with multi-layered subpages
2. Make single drop down menus customizable individually.

2 Kommentare zu “dropdown plugin”

  1. Stephenq,

    Thanks for sharing this! can you make it so that I can link my own url’s? I dont want to create the subpages with child pages, I want to specify my pageid. Sorry if this is an obvious question….is there another way i can do it now with your current release? Thanks.

  2. Luca,

    It doesn’t work , subpages are not shown

  3. stefan,

    do you have some more information? maybe try the new plugin without javascript.


akzent