This is one for the website. As previously mentioned, I'm not a Yii coder - I fiddle with the front-end, Yii generated code, CSS etc. but I also need to know how to use things like CHtml. However I don't touch the database or Yii itself, and I have no idea how it all works - neither do I have time to learn. I probably wouldn't understand it anyway.
I’m forever referring to this page for reference: http://www.yiiframew…m/doc/api/CHtml however there are NO examples on how to use the code in context anywhere. It’s extremely frustrating as I have to go and find some code elsewhere and learn from that.
Could the website be updated to include example code in the reference sections? I’m sure this would be helpful even to those hardened programmers who’ve done the tutorials and read the manual (and understand it)
I'm forever referring to this page for reference: http://www.yiiframew...m/doc/api/CHtml
however there are NO examples on how to use the code in context anywhere. It's extremely frustrating as I have to go and find some code elsewhere and learn from that.
I had similar problems and sometimes still have them . But what I found out is that unlike other frameworks Yii is actually… simple . So, if you read in reference that Chtml is a static class you just should call its methods without actually creating the object. You can put that example in any view file as it will return html code.
CHtml::link('Thats a link', array('site/index'));
CHtml:: - means we would like to use a method from CHtml static class (not object).
link() - thats a method from CHtml static class and you can find its description in api reference.
I agree that more example would be nice, but IMO classes categories could be even more helpfull as a lot of examples are already in Yii Guide.
All validators are used in the similar way, all widgets are used in the same way, static classes are used in the same way. Core classes are usually only used internally by framework. And there are a few classes which has to be extended like model or controller. So it will be enough to make just a short note about how to use classes from each category with a link to right Yii guide page.
You can use CHtml like this:
<?php echo CHtml::something(parameters) ?>
'something' could be public properties and methods.