[wp-hackers] Options for Controller - Views
Otto
otto at ottodestruct.com
Fri Nov 20 16:26:13 UTC 2009
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.
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.
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.
-Otto
Sent from Memphis, TN, United States
More information about the wp-hackers
mailing list