Should All Menu Links Go Through /site/ ?

I installed Yii on my local machine this weekend and have a question about the siteController. I created a bunch of models,views, and controllers using gii. I can access those controllers directly by going to www.mysite.com/controller_name. While looking at the default install and views/layouts/main.php I noticed the default nav-menu links go through the site controller so the url looks like www.mysite.com/site/about. I took a peek at the siteController and it shows the various actions for those pages.

I am wanting to add new links my nav menu and some new pages/views to my site but I don’t know if I should go through the site controller or just access the controllers directly. Does it matter? I may be entirely misunderstanding the purposes of the various controllers. I’m brand new to MVC. Here is a snippet of the code I was looking at.

views/layouts/main.php




    <?php $this->widget('zii.widgets.CMenu',array(

					'items'=>array(

						array('label'=>'Home', 'url'=>array('/site/index')), //uses the site controller

						array('label'=>'About', 'url'=>array('/site/page',    'view'=>'about')),

						array('label'=>'Contact', 'url'=>array('/site/contact'),

                                              array('label'=>'User', 'url'=>array('/user')), //directly accesses the user controller. Is one method preferred over the other?

					),

					'htmlOptions'=>array(

						'class'=>'nav',

					),

				)); ?>




If possible, I would like to be consistent and either use www.mysite.com/site/other-pages or www.mysite.com/other-pages for everything. I’ve already removed index.php using .htaccess which is why I didn’t show it.

Hi, and be welcome to the forum!

The SiteController has a few useful and example actions. You are free to create your own controllers and actions.

You can even remove the SiteControler and have the login at, for example /user/login (using a UserController and actionLogin).

I hope this helps!

Please post again if you need further clarifications.