[wp-hackers] Options for Controller - Views
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('generate_rewrite_rules', array(__CLASS__,'add_rewrite_rules'));
>> add_filter('query_vars', array(__CLASS__,'add_queryvars' ));
> 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
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.
WordPress Custom Plugins
More information about the wp-hackers