I am trying to change the styling of the gridview, tableview, & detailview. I found something saying that I should change the config/main.php file to this:
...
// application components
'components'=>array(
'user'=>array(
// enable cookie-based authentication
'allowAutoLogin'=>true,
),
'bootstrap'=>array(
'class'=>'bootstrap.components.Bootstrap',
),
'widgetFactory'=>array(
'widgets'=>array(
'CGridView'=>array(
'cssFile' => Yii::app()->request->baseUrl.'/css/table_and_grid.css',
),
),
),
...
I have removed the assets folder that is generated by the app, but that didn't help. When I load the view, I can see that the css sheet is being loaded into the header of the page, but none of the styling is working. Why? How do I fix?
I haven't seen anything about changing the style of CGridView in main config file(main.php), But you can customize CGridView styles with bellow parameters:
$this->widget('zii.widgets.grid.CGridView', array(
'id'=>'SOME ID',
'dataProvider'=>$YOUR_DATA_PROVIDET,
'cssFile'=>'...',
'baseScriptUrl'=>'...',
'filterCssClass'=>'...',
'itemsCssClass'=>'...',
'pagerCssClass'=>'...',
'rowCssClass'=>'...',
'summaryCssClass'=>'...',
));
You can change ... with your own.
for more information you can check CGridView's Official document on the following link:
CGridView
Related
I'm new to Yii. I'm developing a system with YII framework in PHP. How can I have a different layout for different module? I want the module A to have interface A, module B with interface B. But what I have know is that the interface login is the same for all module login. Can someone give me a light?
Update:
I found one way which is to include the:
$this->layout = $layout;
on the action function inside the controller before rendering the page. However, I found that it's not that efficient as on every action I need to repeat the line. Is there a way where we can do the setting on the config/main.php page? probably on this part:
'modules'=>array(
'gii'=>array(
'class'=>'system.gii.GiiModule',
'password'=>'123',
'generatorPaths' => array('bootstrap.gii'),
),
'admin',
'consultant',
'client',
),
You can set variables for your module in your config like this:
'modules'=>array(
'gii'=>array(
'class'=>'system.gii.GiiModule',
'password'=>'123',
'generatorPaths' => array('bootstrap.gii'),
),
'admin' => array(
'layout' => 'your_layout' //The layout for this module
),
'consultant',
'client',
),
This way you can implement a default layout for every single module. Without having to add controller methods or variables.
For more info see the docs: here and here
try this:
class YourController extends Controller {
public $layout = 'your_layout';
}
I'm trying to understand how spiffy-navigation works. I integrate the module, it's working very well. I have my navigation.
But the doc says :
Rbac specific options
role: required The role to use to determine if access is granted.
permission: required The permission to use to determine if access is
granted.
But, even if i did something like that, it still not working.
'containers' => array(
'default' => array(
array(
'options' => array(
'label' => 'profil',
'route' => 'profil',
'role' => 'members',
'permission' => 'member'
),
'pages' => array(
// ...
)
)
)
),
EDIT(May 27) :
This is in fact a try of this discussion :ZF2 Generate navigation using zfcrbac zfcUser and hierarchical role strategy
My Question is the same :
How to generate a dynamic navigation, for a user wich can only see links that is granted to access ?
For example when you write this :
<?php echo $this->navigation('navigation')->menu()->setUlClass('nav navbar-nav')?>
In our layout in ZF2 without zfcRbac we can specify getAcl(), setAcl(), getRole() and setRole(), gets and sets ACL (Zend\Permissions\Acl) but with zfcRbac this didn't work.
Spiffy Navigation need to be improved for doing that(it's the prototype of zf3 navigation). It's not the aim of ZfcRbac module.
if someone has a solution it would be nice.
'errorHandler' => array(
'class' => 'ErrorHandler',
'errorAction' => 'page/find',
),
http://shot.qip.ru/008pAk-4IA4wMhU6/
I have standard error handling with beautiful error page. But for develop environment I need standard stacktrace on it below.
Examlpe: http://shot.qip.ru/008pAk-4IA4wMhU7/
If I comment 'errorAction' I can see just standart stacktrace, in other case I cant display this stacktrace.
'log'=>array(
'class'=>'CLogRouter',
'routes'=>array(
array(
'class' => 'CWebLogRoute',
'categories' => 'application, exception.*',
'levels'=>'error, warning, trace, profile, info',
'showInFireBug' => true,
'enabled' => YII_DEBUG,
),
array(
'class'=>'ext.yii-debug-toolbar.YiiDebugToolbarRoute',
'ipFilters'=>array('127.0.0.1','192.168.0.100'),
),
array(
'class'=>'CProfileLogRoute',
'report'=>'summary',
// Shows the execution time of each labeled with a code block.
// The value of "report" can also be specified as a "callstack".
),
),
),
Error handler by default uses two types of views for
Production named as error.php;
Development named as named as exception.php;
Based on your routing and error handler code. I see you have defined a custom error action
You will have to place your custom Errors views in either of the following folders, in the format specified in the link below and use the standard error action.
themes/ThemeName/views/system: when a theme is active.
protected/views/system
See this Documentation for detailed explanation
Reference: http://www.yiiframework.com/doc/api/1.1/CErrorHandler
Try this extenstion http://www.yiiframework.com/extension/yii-debug-toolbar/
The Yii Debug Toolbar is a configurable set of panels that display various debug information about the current request/response and when clicked, display more details about the panel's content.
It is a ported to PHP famous Django Debug Toolbar.
I have Two modules Albums And Signup. I need to set layout in Signup module.My difficulty is here , i need to set a layout.phtml for a page in signup module , but layout.phtml is residing in Album module.
Try using the EdpModuleLayouts https://github.com/EvanDotPro/EdpModuleLayouts
"Using EdpModuleLayouts is very, very simple. In any module config or autoloaded config file simply specify the following:"
array(
'module_layouts' => array(
'Album' => 'layout/album',
'Signup' => 'layout/signup',
),
);
I am new to the beautiful Yii Framework. So I am just going through the tutorials and documentation. So I am doing the blog tutorial from starting. So for blog application I made export the database from the blog folder which comes with Yii to MySQL. Again I decided to use Yii User module and for that I made export the user module database to MySQL. Now my problem is that when I am using login in the application it is showing some error like this
Trying to get property of non-object
I both tried index.php?r=site/login and also index.php?r=user/login both failed. So can some one tell me how to solve this. FYI in my database there are two fields like 'ia_user' which is imported from the blog folder and 'ia_users' which is imported from the Yii User module folder. So is there any thing wrong. Below I am pasting the configuration of main.php file.
<?php
// uncomment the following to define a path alias
// Yii::setPathOfAlias('local','path/to/local-folder');
// This is the main Web application configuration. Any writable
// CWebApplication properties can be configured here.
return array(
'basePath'=>dirname(__FILE__).DIRECTORY_SEPARATOR.'..',
'name'=>'My Blog Application',
// preloading 'log' component
'preload'=>array('log'),
// autoloading model and component classes
'import'=>array(
'application.models.*',
'application.components.*',
/*user module starts here*/
'application.modules.user.models.*',
'application.modules.user.components.*',
/*user module ends here*/
),
'modules'=>array(
// uncomment the following to enable the Gii tool
/*
'gii'=>array(
'class'=>'system.gii.GiiModule',
'password'=>'Enter Your Password Here',
// If removed, Gii defaults to localhost only. Edit carefully to taste.
'ipFilters'=>array('127.0.0.1','::1'),
),
*/
),
// application components
'components'=>array(
'user'=>array(
// enable cookie-based authentication
'allowAutoLogin'=>true,
/*user module starts here*/
'loginUrl' => array('/user/login'),
/*user module ends here*/
),
// 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' => 'sqlite:'.dirname(__FILE__).'/../data/testdrive.db',
//),
// uncomment the following to use a MySQL database
'db'=>array(
'connectionString' => 'mysql:host=localhost;dbname=tbl_blog',
'emulatePrepare' => true,
'username' => 'root',
'password' => 'root',
'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'=>'webmaster#example.com',
),
);
Please help me out.Any help and suggestions will be highly appreciable.I asked help from Yii forum but not got any reply So I am asking for help here .
I had to add user in array of modules just like this
'user'=>array(
'user'
// enable cookie-based authentication
'allowAutoLogin'=>true,
/*user module starts here*/
'loginUrl' => array('/user/login'),
/*user module ends here*/
),