I’m trying to set up an extended version of CHtml that checks user states before displaying links in a view. To make this work, I need to identify Yii action links as opposed to arbitrary non-action links. I also have to allow for other types of links that are formatted like actions (e.g. helpIndex.)
Any ideas how to efficiently check all controllers to see if something is an action, for both function and class actions? I fear that I’ll have to register all actions somehow.
I have my fingers crossed that there is some function that will fail if fed a non-action string, but has no substantial side effects.
Well, I haven’t found a reasonably efficient way to do this (efficient since this will be called for every link on most pages), so I’ve decided to simply rewrite [font=“Courier New”]CHtml::link()[/font] to assume that the url parameter is an action. Any non-action urls will have to be manually specified with the old version of the function, either directly, or by way of a newly created [font=“Courier New”]linkStatic()[/font] wrapper function.
I’m still curious if anyone knows of a good way to make links display conditionally, where actions are automatically identified and handled differently than external urls.