That's ought to be one of the smallest Yii extensions around... .
if this is front-page
print some stuff
end if
if (Yii::app()->isFrontPage()) { // render special widgets, print some stuff, etc... }
The requirements are really minimal :) . Just make sure to follow the installation instructions and you're clear for takeoff.
// ... 'behaviors' => array( 'isFrontPageTeller' => array( 'class' => 'application.components.PcIsFrontpage', ) ), // ...
I have some doubts that this isn't achievable by other means. Also, maybe you have some reservations on the implementation (the behavior method implementation). In case you have this important feedback please do not spare it from me :) ... (TIA)
Total 5 comments
New improved extension over this one has been added here http://www.yiiframework.com/extension/pagechecker/
I see what you mean. The design consideration I described earlier regarding this tiny component feels wrong when put on the same line with the more well known, and much more function-rich app components - is still the same. Further more, AFAIK, even if I did this as an application component:
but CBehavior extends CComponent and CComponent can be used with Yii::app()->isFrontPage() too.
I'm not sure I'm following: why did I made it a CBehavior and not an application component? Because in my humble design eyes this is simpler and more appropriate: A full blown application component looks like an overkill for this task even if Yii manages app components leanly. Can I put on the same line this meager component with other components like urlManager, authManager, db, log, etc... ?
I felt that a mere 1 line(!) behavior class that is easily and intuitively used with Yii::app()->isFrontPage() was a good KISS design.
why CBehavior not CComponent or even without extend ?
Leave a comment
Please login to leave your comment.