Yii Framework Forum: Page Not Found Message Error - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Page Not Found Message Error Rate Topic: -----

#1 User is offline   guim 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 12
  • Joined: 16-September 12

Posted 16 September 2012 - 06:17 PM

Hi everyone,

when I click one the menu item of my page, I get this error message "The requested URL /testYii/index.php/mywebpages/view/controllers/introduction was not found on this server". Could anyone help me fix the issue please?

My control file name is MywebpagesController.php and this is it content:

//MywebpagesController.php

<?php
	class MywebpagesController extends Controller
	{
		public function actionIndex()
		{
			$this->render('index');
		}
	
		public function actionIntroduction()
		{
			$this->render('introduction.php');
		}

		public function actionIntroduction()
		{
			$this->render('introduction');
		}
	}
?>


This is my /protected/views/layouts/main.php file content:

	<div class="backgroundGeneral">
		<div id="mainmenu">
			<?php $this->widget('zii.widgets.CMenu',array(
				'items'=>array(
					array('label'=>'Accueil', 'url'=>array('/site/index')),
					array('label'=>'Teaching', 'url'=>array('/mywebpages', 'view'=>'controllers/introduction')),
					array('label'=>'About', 'url'=>array('/site/page', 'view'=>'about')),				
					array('label'=>'login', 'url'=>array('/site/login'), 'visible'=>Yii::app()->user->isGuest),
					array('label'=>'Logout ('.Yii::app()->user->name.')', 'url'=>array('/site/logout'), 'visible'=>!Yii::app()->user->isGuest),
					array('label'=>'Forum', 'url'=>array('/site/pages/forum')),
					array('label'=>'Tools', 'url'=>array('/site/pages/tools')),
					array('label'=>'Contact', 'url'=>array('/site/contact')),
				),
			)); ?>
</div><!-- mainmenu -->


This is the /protected/config/main.php file content

return array(
	'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
	'name'=>'My web site',
	//gtf ... 'defaultController' => 'home',

	// preloading 'log' component
	'preload'=>array('log'),

	// autoloading model and component classes
	'import'=>array(
		'application.models.*',
		'application.components.*',
		'application.controllers.*', //
		'application.classes.*', //

	),
		'urlManager'=>array(
			'urlFormat'=>'path',
			'rules'=>array(
				'<controller:\w+>/<id:\d+>'=>'<controller>/view',
				'<controller:\w+>/<action:\w+>/<id:\d+>'=>'<controller>/<action>',
				'<controller:\w+>/<action:\w+>'=>'<controller>/<action>',
			),
			'showScriptName'=>true,
		),


Finally, I have the following configuration:

-/protected/views/site/pages/introduction.php
-/protected/controllers/MywebpagesController.php


Thank you in advance
0

#2 User is offline   ORey 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,701
  • Joined: 20-April 09
  • Location:Moscow, Russia

Posted 16 September 2012 - 06:23 PM

Obviously, you have a wrong URL generated by Menu component.
The right one should be "/mywebpages/introduction".

I think you should change
'url'=>array('/mywebpages', 'view'=>'controllers/introduction')
to
'url'=>array('/mywebpages/introduction')
but check the documentation on this (I have no idea how zii.widgets work)
God is real unless declared as integer
0

#3 User is offline   guim 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 12
  • Joined: 16-September 12

Posted 16 September 2012 - 08:23 PM

Thank you ORey for your answer. I set this url
'url'=>array('/mywebpages/introduction')
There is no longer error. Instead I've now a full white page.
0

#4 User is offline   ORey 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,701
  • Joined: 20-April 09
  • Location:Moscow, Russia

Posted 16 September 2012 - 09:44 PM

You have two actions with the same name (I wonder why exception was not thrown), view in the unusual place and so on.
Plz start with the blog tutorial.
God is real unless declared as integer
0

#5 User is offline   alirz23 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 1,203
  • Joined: 08-August 12
  • Location:Durban, South Africa

Posted 17 September 2012 - 07:24 AM

public function actionIntroduction()
                {
                        $this->render('introduction.php');
                }



remove this action from your controller I think this action is causing problem
0

#6 User is offline   guim 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 12
  • Joined: 16-September 12

Posted 18 September 2012 - 06:55 PM

I did not put the word "Controller" into the name of the controller file. That was the cause of the trouble.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users