0
我有一個使用Yii bootstrap框架開發它的網站。然後,我只是想創建註釋模塊,其中該模塊我從Yii的下載它(該鏈接低於):Yii模塊只能在本地主機上使用,但不能在網站上使用
然後我已經測試過它在我的本地和它的作品。然而,評論模塊在我的網站上不起作用。
下面是我的主要代碼:
<?php
require_once(dirname(__FILE__) . '/../components/Helper.php');
// uncomment the following to define a path alias
// Yii::setPathOfAlias('local','path/to/local-folder');
Yii::setPathOfAlias('bootstrap', dirname(__FILE__).'/../extensions/bootstrap');
Yii::setPathOfAlias('CoverUploadDir', dirname(__FILE__).'/../../uploads/covers');
Yii::setPathOfAlias('ContentsUploadDir', dirname(__FILE__).'/../../uploads/contents');
error_reporting(E_ALL^E_NOTICE);
// This is the main Web application configuration. Any writable
// CWebApplication properties can be configured here.
return array(
'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
'name'=>'Smart Mobile Library',
'theme' => 'bootstrap',
// preloading 'log' component
'preload'=>array('log'),
// autoloading model and component classes
'import'=>array(
'application.models.*',
'application.components.*',
),
'modules'=> array(
'comments'=>array(
//you may override default config for all connecting models
'defaultModelConfig' => array(
//only registered users can post comments
'registeredOnly' => true,
'useCaptcha' => true,
//allow comment tree
'allowSubcommenting' => true,
//display comments after moderation
'premoderate' => false,
//action for posting comment
'postCommentAction' => 'comments/comment/postComment',
//super user condition(display comment list in admin view and automoderate comments)
'isSuperuser'=>'Yii::app()->user->isAdmin()',
//order direction for comments
'orderComments'=>'DESC',
),
//the models for commenting
'commentableModels'=>array(
//model with individual settings
'Book'=>array(
'registeredOnly'=>true,
'useCaptcha'=>true,
'allowSubcommenting'=>false,
//config for create link to view model page(page with comments)
'pageUrl'=>array(
'route'=>'/admin/book',
'data'=>array('id'=>'book_id'),
),
),
//model with default settings
'ImpressionSet',
),
//config for user models, which is used in application
'userConfig'=>array(
'class'=>'User',
'nameProperty'=>'fullname',
'emailProperty'=>'email',
),
),
'gii'=>array(
'class'=>'system.gii.GiiModule',
'password'=>'lovesick',
'ipFilters'=>array('127.0.0.1','::1'),
'generatorPaths'=>array(
'bootstrap.gii',
),
),
),
// application components
'components'=>array(
'counter' => array(
'class' => 'bootstrap.components.UserCounter',
),
'bootstrap'=>array(
'class'=>'bootstrap.components.Bootstrap',
),
'user'=>array(
'allowAutoLogin'=>true,
'class' => 'Admin',
),
// uncomment the following to enable URLs in path-format
/*
'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>',
),
),
*/
'db'=>array(
'connectionString' => 'mysql:host=127.0.0.1;dbname=smartmob_administrators',
'emulatePrepare' => true,
'username' => 'donkey',
'password' => 'donkey1001',
'charset' => 'utf8',
'tablePrefix' => 'tbl_',
),
'errorHandler'=>array(
// use 'site/error' action to display errors
'errorAction'=>'site/error',
),
'log'=>array(
'class'=>'CLogRouter',
'routes'=>array(
array(
'class'=>'CFileLogRoute',
'levels'=>'error, warning',
),
// uncomment the following to show log messages on web pages
/*
array(
'class'=>'CWebLogRoute',
),
*/
),
),
),
// application-level parameters that can be accessed
// using Yii::app()->params['paramName']
'params'=>array(
// this is used in contact page
'adminEmail'=>'[email protected]',
),
);
我按照已經給出,我真的不知道是什麼問題的所有規定。每當我叫下面
$this->widget('comments.widgets.ECommentsListWidget', array( 'model' => $model,));
這個別名不會顯示任何錯誤,但是在我所有的主題,走了我的頁面會變成白色。它只顯示了內容和沒有評論模塊。我認爲我的網址管理器有問題。我試圖執行下面的代碼,但仍然沒有成功
'<modules:\w+>/<controller:\w+>/<action:[\w-]+>' => '<modules>/<controller>/<action>',
'<modules:\w+>/<controller:\w+>' => '<modules>/<controller>',
'<modules:\w+>' => '<modules>',
我覺得y使用錯誤的別名'comment.views.comment.commen tList'這很奇怪,並且這個路徑不能存在。在文檔中說'$ this->小部件('comments.widgets.ECommentsListWidget',array( 'model'=> $ model, ));'並且不渲染。 – ineersa
owh我的錯誤...我想我從我的其他來源複製它。我使用了這個別名'$ this-> widget('comments.widgets.ECommentsListWidget',array('model'=> $ model,));'並且它給了我我提到的錯誤 – AsySyah