NAVT Plugin For WordPress

By Greg Bellucci, April 2007

Introduction

The information in this document is not intended to teach the basics of the PHP programming language, programming logic or WordPress template construction. It is designed to provide sensible help to the "do it yourselfer" who would like to use the NAVT Plugin for WordPress and isn't afraid to do a little template hacking to make it happen.

Template 'hacking' is the very thing I hope to avoid by supplying you with this information. Adding the necessary function call to your WordPress template for the NAVT plugin doesn’t take very long to do. You need to understand the following three things:

WordPress Theme Basics

WordPress templates are not a mystery if you understand what is going on. The content of your WordPress theme directory is composed of one large PHP script. The script is divided into small files and each file name provides a clue for its intended use.

The typical WordPress theme usually contains (at a minimum) the following four files:

The Index.php file contains the PHP scripting that is responsible for assembling all of the information that produces the pages of your WordPress blog. Index.php calls the PHP function get_header() and the scripting code for the get_header function is in your header.php file. It also calls the PHP function get_sidebar() and, as luck would have it, the scripting code for the sidebar is contained in the sidebar.php file. Index.php also calls the function get_footer() and guess where the scripting code for the footer is? That’s right, in your footer.phpfile.

Index.php also contains the logic necessary to fetch the pages, articles and comments from your database and display them between the header and the footer of each page. Your theme's stylesheet (the file called style.css) contains the instructions your browser needs to display each of your web blog pages.

Where are the Menus?

Depending on how your theme was constructed, the scripting for the navigation lists that appear in your theme can theoretically be located anywhere. We can narrow down the possible location by making an educated guess. If your theme has a horizontal navigation bar then the scripting code is probably located in the file: header.php If your theme uses a vertical navigation list, then the code is probably located in the file: sidebar.phpThese are the two standard locations for theme navigation lists.

To locate the actual line of PHP code in header.php, sidebar.php or in any file of your theme, do the following:

wp_list_pages is a core WordPress PHP function call so it will appear in the file with between: <?php and ?> . The entire line may look similar to: <?php wp_list_pages('title_li=' . __('Pages:')); ?>

PHP script is executed on the server in a top-down fashion; beginning with the very first line of PHP code at the top of the file and continuing to the last line at the bottom. At the point where the wp_list_pages is encountered on the page, the function call produces all of the necessary HTML code to display the navigation list.

 

 

NAVT Plugin For Word Press

PHP Interface function call syntax:

navt_getlist($sNavGroupName, $bEcho=true, $sTitle='', $sBefore='ul', $sAfter='/ul', $sBeforeItem='li', $sAfterItem='/li')

Where:

string $sNavGroupName (no default - note: you cannot specify the 'unassigned' menu group)
The name of the requested navigation group- Note: the name *must* match the group name you defined when the group was created.

boolean $bEcho (default = true)
Instructs the function to echo the html output. If set to false, the output is returned.

string $sTitle (default='')
An optional title to appear before the menu. You may specify tags/class (example:"<h3 class="cls">Menu Title</h3>" )

string $sBefore (default = 'ul')
The opening tag(s) that encapsulates the menu (without the beginning or ending angle brackets) Combinations of tags can be used as in:
"ul><div class="my_menu_class"
(Note that the beginning and ending angle brackets are not included.

string $sAfter (default = '/ul')
The closing tag(s) that match the $sBefore tag (without the beginning or ending angle brackets) Use the closing tag combinations for
multiple tags as in: "/div></ul" (for the $sBefore example above.)

string $sBeforeItem (default = 'li')
The opening tag(s) that encapsulates each menu item (without the beginning or ending angle brackets).

string $sAfterItem (default = '/li')
The closing tag(s) that matches the tags used in $sBeforeItem (without the beginning or ending angle brackets).

return HTML formatted output or NULL if $bEcho = true


NAVT Navigation Tool for Word Press
Copyright © 2006-2007 Greg A. Bellucci
The MIT License