Missing: Simple Examples

I’d just like to make a comment.

I am new to the Yii framework and community, I have a background in .NET and Ruby on Rails and I am looking for a PHP framework I can learn and be a part of the community. That said, I have developed a simple app in Yii and have been impressed so far.


Where are the simple examples of common functionality??? For instance, I can’t find any example in the documentation of how to use the “CHtml::link()” method. By example I mean one that shows how to code a link to an action, one that shows how to code a link to an action with some querystring params, etc.

Not sure if most of the community here has come from other frameworks that are similar and don’t need these types of examples but as a new developer wanting to learn this framework they are essential and in my opinion should be a part of the class reference documentation.


If the community needs someone to document these examples I can do so, but I will be in the forum asking many questions!


But, since the framework hasn’t 1 year officialy yet, it’s normal to not have a fully documentation.


I know that the docs could be a little better (with hands-on example) but I think for starters, this is pretty good - http://www.yiiframework.com/doc/api/CHtml#link-detail

And if you go through the blog tutorial, it shows you bunch of stuff.


Agree that the guide is missing a page with examples for all the CHtml methods. That would be really cool. So how about creating one and contributing it to the community? ;)

I’d be happy to.

This is the link I want to create

<a href="index.php?r=apg/DeleteNews&id=<?php echo $row->id ?>">Delete Article</a>

But I want it generated by CHtml::link(), how do I do that? I tried several attempts without success.



<?php echo CHtml::link('Delete Article',array('apg/DeleteNews', 'id'=> $row->id)); ?>

Knew it was something simple and I was over complicating it. Maybe I am having trouble reading the class reference.

So can the parameter list be an array like ?

<?php echo CHtml::link('Delete Article',array('apg/DeleteNews', array('id'=> $row->id, 'id2'=> $row->id2))); ?>

Is there a wiki for Yii yet that I can use to build some example documentation ?

I can create one elsewhere if needed.

Sure, but you don’t need to create another array:

<?php echo CHtml::link('Delete Article',array('apg/DeleteNews','id'=> $row->id, 'id2'=> $row->id2)); ?>

I wouldn’t start a Wiki somewhere else. It’s always good to find all kind of information in a central place like the yii website. I’m sure they will create one if more requests come up for it.

But i’m sure Qiang will be pleased to include another page to the docs if you want to create one. Maybe that’s a nice idea for a little community effort? ;)

You may share your experience here: http://www.yiiframework.com/doc/cookbook/

Everyone can participate and maintain the page you create. It’s just like wiki.

Qiang, Thanks for the direction! I look forward to authoring some more detailed example pages for the community.

I have created the first in the series using the cookbook called "By Example: CHtml"

Additionally, I really appreciate your effort with Yii and your vision to mix the best of many frameworks.