kaelwithme
(Kaelwithme)
September 16, 2010, 9:32am
1
i have this in the my index.php
$this->menu=array(
array('label'=>'Create content', 'url'=>array('create')),
array('label'=>'Manage content', 'url'=>array('admin')),
);
but php can’t read it… i mean obviously not coz i dun have anything related to it in my site’s main Controller.
this error pops up:
CException
Description
Property "ContentController.menu" is not defined.
Source File
C:\xampp\htdocs\viasatondemand\admin\protected\views\content\index.php(4)
00001: <?php
00002:
00003:
00004: $this->menu=array(
00005: array('label'=>'Create content', 'url'=>array('create')),
00006: array('label'=>'Manage content', 'url'=>array('admin')),
00007: );
00008: ?>
00009: <p><center><em>Welcome to the Administrator Section</em></center></p>
00010:
00011:
00012: <h1>Contents</h1>
00013:
00014: <?php $this->widget('zii.widgets.CListView', array(
00015: 'dataProvider'=>$dataProvider,
00016: 'itemView'=>'_view',
Stack Trace
#0 C:\xampp\htdocs\viasatondemand\admin\protected\views\content\index.php(4): CComponent->__set('menu', Array)
#1 C:\xampp\yii\framework\yiilite.php(2851): require('C:\xampp\htdocs...')
#2 C:\xampp\yii\framework\yiilite.php(2830): CBaseController->renderInternal('C:\xampp\htdocs...', Array, true)
#3 C:\xampp\yii\framework\yiilite.php(3220): CBaseController->renderFile('C:\xampp\htdocs...', Array, true)
#4 C:\xampp\yii\framework\yiilite.php(3197): CController->renderPartial('index', Array, true)
#5 C:\xampp\htdocs\viasatondemand\admin\protected\controllers\ContentController.php(146): CController->render('index', Array)
#6 C:\xampp\yii\framework\yiilite.php(3430): ContentController->actionIndex()
#7 C:\xampp\yii\framework\yiilite.php(3002): CInlineAction->run()
#8 C:\xampp\yii\framework\yiilite.php(5655): CController->runAction(Object(CInlineAction))
#9 C:\xampp\yii\framework\yiilite.php(5664): CFilterChain->run()
#10 C:\xampp\yii\framework\yiilite.php(3334): CFilter->filter(Object(CFilterChain))
#11 C:\xampp\yii\framework\yiilite.php(5697): CController->filterAccessControl(Object(CFilterChain))
#12 C:\xampp\yii\framework\yiilite.php(5652): CInlineFilter->filter(Object(CFilterChain))
#13 C:\xampp\yii\framework\yiilite.php(2992): CFilterChain->run()
#14 C:\xampp\yii\framework\yiilite.php(2977): CController->runActionWithFilters(Object(CInlineAction), Array)
#15 C:\xampp\yii\framework\yiilite.php(1542): CController->run('index')
#16 C:\xampp\yii\framework\yiilite.php(1434): CWebApplication->runController('content/index')
#17 C:\xampp\yii\framework\yiilite.php(1049): CWebApplication->processRequest()
#18 C:\xampp\htdocs\viasatondemand\admin\index.php(11): CApplication->run()
#19 {main}
how do i fix this? T_T
mdomba
(Maurizio Domba Cerin)
September 16, 2010, 9:40am
2
As it says you don’t have $menu defined in ContentController…
kaelwithme
(Kaelwithme)
September 16, 2010, 9:46am
3
yeah i know… how do i do that?.. i can’t find any format to follow for writing it.,
kaelwithme
(Kaelwithme)
September 16, 2010, 9:47am
4
can i do it with a public function inside the class?
for instance something like this?
public function menu()
{
}
mdomba
(Maurizio Domba Cerin)
September 16, 2010, 9:53am
5
In the code generated automatically by Gii $menu is defined in components/Controller.php as public $menu=array() as a property of the Controler class
All other controlers extend from Controler class… maybe you extended your controler from CControler and so you don’t have ‘menu’?
kaelwithme
(Kaelwithme)
September 16, 2010, 10:09am
6
mdomba:
In the code generated automatically by Gii $menu is defined in components/Controller.php as public $menu=array() as a property of the Controler class
All other controlers extend from Controler class… maybe you extended your controler from CControler and so you don’t have ‘menu’?
yeah i think i did extend from CControler… t’was because when i extend from Controler this error pops up:
PHP Error
Description
include(Controller.php) [<a href='function.include'>function.include</a>]: failed to open stream: No such file or directory
Source File
C:\xampp\yii\framework\yiilite.php(192)
00180: else
00181: self::$_aliases[$alias]=rtrim($path,'\\/');
00182: }
00183: public static function autoload($className)
00184: {
00185: // use include so that the error PHP file may appear
00186: if(isset(self::$_coreClasses[$className]))
00187: include(YII_PATH.self::$_coreClasses[$className]);
00188: else if(isset(self::$_classes[$className]))
00189: include(self::$_classes[$className]);
00190: else
00191: {
00192: include($className.'.php');
00193: return class_exists($className,false) || interface_exists($className,false);
00194: }
00195: return true;
00196: }
00197: public static function trace($msg,$category='application')
00198: {
00199: if(YII_DEBUG)
00200: self::log($msg,CLogger::LEVEL_TRACE,$category);
00201: }
00202: public static function log($msg,$level=CLogger::LEVEL_INFO,$category='application')
00203: {
00204: if(self::$_logger===null)
?_?
mdomba
(Maurizio Domba Cerin)
September 16, 2010, 10:20am
7
as the error says it cannot find Controler.php… so check if the file exists in protected/components … and if in config/main.php under import you have ‘application.components.*’
If you still get some errors… then create a new webapp with yiic it creates all this settings and then add your controller to see if it works there…
kaelwithme
(Kaelwithme)
September 16, 2010, 10:30am
8
mdomba:
as the error says it cannot find Controler.php… so check if the file exists in protected/components … and if in config/main.php under import you have ‘application.components.*’
If you still get some errors… then create a new webapp with yiic it creates all this settings and then add your controller to see if it works there…
i have this in my main config
$admin=dirname(dirname(__FILE__));
$frontend=dirname($admin);
Yii::setPathOfAlias('admin', $admin);
return array(
/*'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'../protected',*/
'basePath'=> $frontend.'/protected',
'runtimePath'=>$admin.'/runtime',
'controllerPath' => $admin.'/protected/controllers',
'viewPath' => $admin.'/protected/views',
'name'=>'Admin',
'sourceLanguage'=> 'en_US',
'language' => 'ee',
'timeZone' => 'Europe/Stockholm',
// preloading 'log' component
//'preload'=>array('log'),
// autoloading model and component classes
'import'=>array(
'admin.models.*',
'admin.components.*',
'application.models.*',
'application.components.*',
),
i have controller.php in my components folder…
class Controller extends CController
{
/**
* @var string the default layout for the controller view. Defaults to '//layouts/column1',
* meaning using a single column layout. See 'protected/views/layouts/column1.php'.
*/
public $layout='//layouts/column1';
/**
* @var array context menu items. This property will be assigned to {@link CMenu::items}.
*/
public $menu=array();
/**
* @var array the breadcrumbs of the current page. The value of this property will
* be assigned to {@link CBreadcrumbs::links}. Please refer to {@link CBreadcrumbs::links}
* for more details on how to specify this property.
*/
public $breadcrumbs=array();
}
it still shows this error…
include(Controller.php) [<a href='function.include'>function.include</a>]: failed to open stream: No such file or directory
kbradwick
(Kbradwick)
September 16, 2010, 3:58pm
9
Try renaming the controller.php to Controller.php (uppercase C)
kaelwithme
(Kaelwithme)
September 17, 2010, 2:57am
10
tried that ady.
anyway… besides that, i got another weird problem…
i tried uploading all the stuff i had in a clients webserver.
everything went fine… except for the admin section [which worked fine on my computer’s local server]
i have a model called ‘content’ and that’s what the admin landing page uses as a content. it runs problem-free on my computer. but on the server it says:
Fatal error: Class 'content' not found in /home/earnpili/public_html/yii/framework/yiilite.php on line 6262
is there something wrong with the directories? i have the slightest idea. i’m a noob.