[wp-hackers] Looking for plugin development guidance
Jennifer Hodgdon
yahgrp at poplarware.com
Sun Nov 11 19:17:57 GMT 2007
Mike Walsh wrote:
> I am looking for suggestions on the best or recommended way to expose new
> functionality to the user facing part of the web site. My initial thought
> is to automatically generate pages when the plugin is installed for the
> various things I would need (swim meet schedule, results, roster, etc.) to
> expose to the typical user.
My advice is to have the plugin define new URLs. For example, you
could make it so that
whatever.com/swim_meets
gives the swim meet schedule that your plugin would generate.
To do this, you need to do some programming with the Query Vars and
Rewrite Rules. See this article in the Codex (Custom Archives and
Permalinks for Custom Archives sections should get you going):
http://codex.wordpress.org/Custom_Queries
You might also need to override template selection using the
template_redirect action, which I guess there is currently not an
article on. Hmmm. Maybe I'd better write one, or add to the Custom
Queries article. There is a very short example on this page:
http://codex.wordpress.org/Plugin_API/Action_Reference
but it is not all that useful.
Well, I'll add that to the To Do list.
Meanwhile, here is part of a template loader function I used for
loading some custom templates for a plugin I did for a client. Of
course, you will also need to write the custom templates and
distribute them with your plugin. But you would need to do that if the
plugin created pages too.
add_action('template_redirect', 'confmgr_template_loader' );
function confmgr_template_loader()
{
global $wp_query;
$template = '';
$q = $wp_query->query_vars;
if( isset( $q[ 'conference' ] ) && isset( $q[ 'sponsors' ])) {
$template = TEMPLATEPATH . "/sponsors.php";
} else if( isset( $q[ 'conference' ] ) && isset( $q[ 'sponsor' ])) {
$template = TEMPLATEPATH . "/featured_sponsor.php";
} // other clauses omitted for sake of brevity
if( strlen( $template ) && file_exists( $template )) {
include( $template );
exit;
}
// if we get here, just use the default WP template chooser
}
Hope this helps,
--Jennifer
--
Jennifer Hodgdon
Poplar ProductivityWare * www.poplarware.com
Web Databases/Scripts * Modeling/Analysis/Palm OS Software
More information about the wp-hackers
mailing list