lalitesh
(Luckyglucks)
January 20, 2014, 6:24am
1
Hello Friends,
I have a default controller named SiteController with some actions in it like: index, aboutcompany etc
When I open my site in browser like: localhost/lucky
The index action is working properly.
On index.php (view) i made a link: echo CHtml::link(‘About Company’, array('site/aboutcompany));
When I click on the link an error appears: The requested url not found on this server.
None of the actions (sitecontroller) are workin except index.
Please suggest me the solution
How to you access aboutcompany page? I mean manually access it? But nevertheless, I have a suggestion.
Change
CHtml::link('About Company', array('site/aboutcompany));
to
CHtml::link('About Company', array('/site/aboutcompany));
and make sure that in your site has actionAboutcompany.
lalitesh
(Luckyglucks)
January 20, 2014, 6:49am
3
jcagentzero:
How to you access aboutcompany page? I mean manually access it? But nevertheless, I have a suggestion.
Change
CHtml::link('About Company', array('site/aboutcompany));
to
CHtml::link('About Company', array('/site/aboutcompany));
and make sure that in your site has actionAboutcompany.
I tried all these things but still its not working.
This is my controller file
I used your site controller and it is working properly, I added the following code to my /protected/views/index.php
<?php
/* @var $this SiteController */
$this->pageTitle=Yii::app()->name;
?>
<?php $this->beginWidget('bootstrap.widgets.TbHeroUnit',array(
'heading'=>Yii::t('language','Welcome to')." ".Yii::t('language',CHtml::encode(Yii::app()->name)),
'htmlOptions'=>array('style'=>'text-align: center'),
)); ?>
<!--<p>Congratulations! You have successfully created your Yii application.</p>-->
<?php $this->endWidget(); ?>
<?php
echo CHtml::link('About Company', array('site/aboutcompany'));
?>
and gave me index.php?r=site/aboutcompany or index.php/site/aboutcompany link which is correct.
BTW: make sure that you aboutcompany.php is in /protected/views/site directory. Other than that I don’t see any issue.
lalitesh
(Luckyglucks)
January 20, 2014, 8:17am
5
jcagentzero:
I used your site controller and it is working properly, I added the following code to my /protected/views/index.php
<?php
/* @var $this SiteController */
$this->pageTitle=Yii::app()->name;
?>
<?php $this->beginWidget('bootstrap.widgets.TbHeroUnit',array(
'heading'=>Yii::t('language','Welcome to')." ".Yii::t('language',CHtml::encode(Yii::app()->name)),
'htmlOptions'=>array('style'=>'text-align: center'),
)); ?>
<!--<p>Congratulations! You have successfully created your Yii application.</p>-->
<?php $this->endWidget(); ?>
<?php
echo CHtml::link('About Company', array('site/aboutcompany'));
?>
and gave me index.php?r=site/aboutcompany or index.php/site/aboutcompany link which is correct.
BTW: make sure that you aboutcompany.php is in /protected/views/site directory. Other than that I don’t see any issue.
Your solution works fine, but this index.php in url is creating problem. To access the page i have to make change in url. Links are not working for different views.
What do you mean that the view does not appear properly? Can you provide screenshot?
lalitesh
(Luckyglucks)
January 20, 2014, 9:47am
7
This is the Yii code for link:
echo CHtml::link('COMPANY', array('site/aboutcompany'));
By looks of it I believe that you enabled urlManager,can you provide the urlmanager settings?