I have some experience in Zend framework. Recently I started to using Yii.
Now I’m trying to find some analogy in this frameworks.
In Zend almost every route has an own name. You can create for instance a next route ‘photos_map’:
$router->addRoute('photos_map',
new Zend_Controller_Router_Route('map/:city', array(
'controller' => 'photos',
'action' => 'map',
'city' => ''
))
);
And using it in view by url helper:
echo $this->url(array(), 'photos_map') // output '/map'
In Zend you can also pass the parameter (in above example it’s city) whether in the initialization or in the url-helper call.
If you want to change urls you can just change param string in the initialization map/:city to whatewer you want. It’s very useful because you don’t need to replace an old-url to a new-url everywhere in your code.
My question is this possible in Yii? I fluently read the documentation and started to thunk that Yii routes are much less powerful. Is this a sacrifice of performance or I missed something?
Routing in Yii is easy and a bit different comparing to Zend. In Yii, a view is rendered using a controller, so to render a view , you will have to call a controller. For eg, you are in the index page of a site and you want to go to preview page.
Now in the controller class, (in this case SiteConroller.php),
If you want to change the url, u can simply change the part $this->render(‘your_view_file.php’);
I hope it helps……….Feel free to ask questions……