[wp-hackers] Options for Controller - Views
Mike Schinkel
mikeschinkel at newclarity.net
Fri Nov 20 16:57:48 UTC 2009
On Nov 20, 2009, at 11:26 AM, Otto wrote:
> Okay looking closer at your rules and what you're doing, this needs to
> be explained further.
>
>> add_action('template_redirect',array(__CLASS__,'custom_url'));
>> add_action('generate_rewrite_rules', array(__CLASS__,'add_rewrite_rules'));
>> add_filter('query_vars', array(__CLASS__,'add_queryvars' ));
>> register_activation_hook(__FILE__,array(__CLASS__,'flush_rewrite_rules');
>
>
> Those four are basically correct and those are how you're doing both
> rewriting and routing.
> - template_redirect for routing
> - generate_rewrite_rules to add your custom rule
> - query_vars to add your custom variables
> - activation hook to flush on plugin activation
>
> Those are the only ones relevant to this conversation. All the rest
> you used are to modify the query and presumably pull out something
> special from the database to display things.
You are correct. But as I said earlier one without the other is, for all practical purposes, pointless.
> Without knowing exactly what they're doing, I can't say whether there
> is an easier way to modify the WP_Query or not. However, your use of
> so many posts_* hooks suggests you're modifying the SQL directly,
> which indeed would be quite fragile. There probably is a better way,
> but again, I can't be sure without knowing what exactly you're doing
> there.
If you can find a better, easier way I'd be extremely grateful.
> Nevertheless, the query is not "rewriting" nor is it "routing". It's
> database access, and if you really wanted, your "view" doesn't have to
> use it at all. It all depends on what exactly you're doing.
Again, one without the other is pointless.
-Mike Schinkel
WordPress Custom Plugins
http://mikeschinkel.com/custom-wordpress-plugins/
More information about the wp-hackers
mailing list