How to override Yii core classes An example with CHtml that demonstrates how to override core classes
Posted 22 March 2012 - 06:40 AM
I am a little new to OOP and Yii, but from what I have learnt so far that sounds like something that could work.
Posted 26 March 2012 - 03:32 PM
That's what i expect from Yii 2.0, too. But meanwhile we need to deal with Yii 1.x and that's what the workaround is for. In 2.0 i'd like to see a pluggable CHtml class for bootstrap, foundation or any other CSS library.
Posted 21 May 2013 - 03:40 AM
STEP 1 ) Copy CHtml.php into protected/components/Html.php
STEP 2 ) Create CHtml.php under protected/components and extend it from Html class.
STEP 3) When the new Yii version is released, update Html.php
Hi, I did just like you said here but it doesn't seem to work, do you have something in your config file ?
'import'=>array( 'application.models.*', 'application.components.*', 'application.extentions.*', 'application.helpers.*', ),
Posted 30 May 2013 - 01:39 AM
Yes, I didn't add this line of code in the import, because I thought that 'application.components.*', will do the job. But I ended up not using this method because I don't want to update that file every time, and some errors might come up somewhere.
Posted 30 May 2013 - 06:15 AM
I don't see any real downsides to that; it just means that the cloned version of the framework will only be useable in projects where you've overridden CHtml.