Page Break: Php Notice

I used the Yii on another system but when i transfer to another system on a local sever it gives the following errors, Only the homepage comes up but other links gives this error message

Undefined variable: models

C:\wamp\www\csrinaction\protected\components\SideMenu.php(20)

08 {

09 $models = PageResource::model()->findAll();

10 }

11 elseif($controller == ‘support’)

12 {

13 $models = PageSupport::model()->findAll();

14 }

15 elseif($controller == ‘about’)

16 {

17 $models = PageAbout::model()->findAll();

18 }*/

19

20 $this->render(‘sidemenu’,array(“models”=>$models,

21

22 ));

23

24 }

25 }

Stack Trace

#0

– C:\wamp\www\framework\web\CBaseController.php(174): SideMenu->run()

169 return ob_get_clean();

170 }

171 else

172 {

173 $widget=$this->createWidget($className,$properties);

174 $widget->run();

175 return $widget;

176 }

177 }

178

179 /**

#1

– C:\wamp\www\csrinaction\protected\views\layouts\column3.php(52): CBaseController->widget("SideMenu")

47

48 <div class="inner_container">

49 <div class="left_container">

50

51

52 <?php $this->widget(‘SideMenu’); ?>

53

54

55 <div class="become">

56 <a href="<?php echo Yii::app()->request->baseUrl; ?>/site/membership"><img src="<?php echo Yii::app()->request->baseUrl; ?>/images/become_partner.jpg" width="200" height="60" /></a>

57 </div><div class="become">

#2

– C:\wamp\www\framework\web\CBaseController.php(127): require("C:\wamp\www\csrinaction\protected\views\layouts\column3.php")

122 $data=$data;

123 if($return)

124 {

125 ob_start();

126 ob_implicit_flush(false);

127 require($viewFile);

128 return ob_get_clean();

129 }

130 else

131 require($viewFile);

132 }

#3

– C:\wamp\www\framework\web\CBaseController.php(96): CBaseController->renderInternal("C:\wamp\www\csrinaction\protected\views//layouts/column3.php", array("content" => " <h2 class="mainheadings">About CiA</h2> <span cla…"), true)

091 {

092 $widgetCount=count($this->_widgetStack);

093 if(($renderer=Yii::app()->getViewRenderer())!==null && $renderer->fileExtension===’.’.CFileHelper::getExtension($viewFile))

094 $content=$renderer->renderFile($this,$viewFile,$data,$return);

095 else

096 $content=$this->renderInternal($viewFile,$data,$return);

097 if(count($this->_widgetStack)===$widgetCount)

098 return $content;

099 else

100 {

101 $widget=end($this->_widgetStack);

#4

– C:\wamp\www\framework\web\CController.php(785): CBaseController->renderFile("C:\wamp\www\csrinaction\protected\views//layouts/column3.php", array("content" => " <h2 class="mainheadings">About CiA</h2> <span cla…"), true)

780 {

781 if($this->beforeRender($view))

782 {

783 $output=$this->renderPartial($view,$data,true);

784 if(($layoutFile=$this->getLayoutFile($this->layout))!==false)

785 $output=$this->renderFile($layoutFile,array(‘content’=>$output),true);

786

787 $this->afterRender($view,$output);

788

789 $output=$this->processOutput($output);

790

#5

– C:\wamp\www\csrinaction\protected\controllers\SiteController.php(76): CController->render("view", array("model" => Pages))

71 // renders the view file ‘protected/views/site/index.php’

72 // using the default layout ‘protected/views/layouts/main.php’

73 $this->layout=’//layouts/column3’;

74 $this->render(‘view’, array(

75 ‘model’ => $this->loadModel(2, ‘Pages’),

76 ));

77 }

78 public function actionVision()

79 {

80 // renders the view file ‘protected/views/site/index.php’

81 // using the default layout ‘protected/views/layouts/main.php’

#6

– C:\wamp\www\framework\web\actions\CInlineAction.php(50): SiteController->actionAbout()

45 $controller=$this->getController();

46 $method=new ReflectionMethod($controller, $methodName);

47 if($method->getNumberOfParameters()>0)

48 return $this->runWithParamsInternal($controller, $method, $params);

49 else

50 return $controller->$methodName();

51 }

52

53 }

#7

– C:\wamp\www\framework\web\CController.php(309): CInlineAction->runWithParams(array())

304 {

305 $priorAction=$this->_action;

306 $this->_action=$action;

307 if($this->beforeAction($action))

308 {

309 if($action->runWithParams($this->getActionParams())===false)

310 $this->invalidActionParams($action);

311 else

312 $this->afterAction($action);

313 }

314 $this->_action=$priorAction;

#8

– C:\wamp\www\framework\web\CController.php(287): CController->runAction(CInlineAction)

282 * @see runAction

283 */

284 public function runActionWithFilters($action,$filters)

285 {

286 if(empty($filters))

287 $this->runAction($action);

288 else

289 {

290 $priorAction=$this->_action;

291 $this->_action=$action;

292 CFilterChain::create($this,$action,$filters)->run();

#9

– C:\wamp\www\framework\web\CController.php(266): CController->runActionWithFilters(CInlineAction, array())

261 {

262 if(($parent=$this->getModule())===null)

263 $parent=Yii::app();

264 if($parent->beforeControllerAction($this,$action))

265 {

266 $this->runActionWithFilters($action,$this->filters());

267 $parent->afterControllerAction($this,$action);

268 }

269 }

270 else

271 $this->missingAction($actionID);

#10

– C:\wamp\www\framework\web\CWebApplication.php(283): CController->run("about")

278 {

279 list($controller,$actionID)=$ca;

280 $oldController=$this->_controller;

281 $this->_controller=$controller;

282 $controller->init();

283 $controller->run($actionID);

284 $this->_controller=$oldController;

285 }

286 else

287 throw new CHttpException(404,Yii::t(‘yii’,‘Unable to resolve the request “{route}”.’,

288 array(’{route}’=>$route===’’?$this->defaultController:$route)));

#11

– C:\wamp\www\framework\web\CWebApplication.php(142): CWebApplication->runController("site/about")

137 foreach(array_splice($this->catchAllRequest,1) as $name=>$value)

138 $_GET[$name]=$value;

139 }

140 else

141 $route=$this->getUrlManager()->parseUrl($this->getRequest());

142 $this->runController($route);

143 }

144

145 /**

146 * Registers the core application components.

147 * This method overrides the parent implementation by registering additional core components.

#12

– C:\wamp\www\framework\base\CApplication.php(162): CWebApplication->processRequest()

157 */

158 public function run()

159 {

160 if($this->hasEventHandler(‘onBeginRequest’))

161 $this->onBeginRequest(new CEvent($this));

162 $this->processRequest();

163 if($this->hasEventHandler(‘onEndRequest’))

164 $this->onEndRequest(new CEvent($this));

165 }

166

167 /**

#13

– C:\wamp\www\csrinaction\index.php(13): CApplication->run()

08 defined(‘YII_DEBUG’) or define(‘YII_DEBUG’,true);

09 // specify how many levels of call stack should be shown in each log message

10 defined(‘YII_TRACE_LEVEL’) or define(‘YII_TRACE_LEVEL’,3);

11

12 require_once($yii);

13 Yii::createWebApplication($config)->run();

Can you post the full code for your SideMenu.php file? Use code tags so that it’s formatted correctly.


18 }*/

Looks like the code before $this->render() is commented out.

Here’s my side menu script

<?php

class SideMenu extends CWidget

{

public function run(){

/*

$controller = Yii::app()->controller->id;

if ($controller == ‘resource’)

{

$models = PageResource::model()->findAll();

}

elseif($controller == ‘support’)

{

$models = PageSupport::model()->findAll();

}

elseif($controller == ‘about’)

{

$models = PageAbout::model()->findAll();

}*/

$this->render(‘sidemenu’,array(“models”=>$models,

));

}

}

On my wampsever if i comment this line out

$this->render(‘sidemenu’,array(“models”=>$models,

));

some links work

but if i uncomment them they stop working

Keith ask You to use code tags so please use it for future questions, and Tsunami told You what is wrong "/* … */" means that your code is commented, You should remove them. Anyway I dont know how it is possible that it worked on another system.