Here is my question: I implement in every Admin view of my models some custom Chtml::Link and Chtml::Ajaxlink which are, almost same, except some variable as the grid’s name. I put that code in my generator in order to have what I want in every view without coding anything. However when I want to change something in one of my button, for example, I have to do it X times, X corresponding of numbers of model I have. So I would like to know if it’s possible to create a class, somewhere, where I’d put all of this item with some parameters. Thanks to that, I would change only my class method chtml::link instead of do it for every admin view.
As it more graphical things, such as “echo chtml::link(…)”, I don’t really know where I can create my class, and how I can call it in my admin.php…
thanks for answering and readings, I created finally my widgets but it doesn’t work and I don’t find my mistake can you just check what can be wrong :
widget :
<?php
class ActionButton extends CWidget {
public $title='My title';
public $directToLink='';
public $csrf='';
public $id='';
public $src='/myApp/images/myImage.gif';
public $style='height:10px; width:10px; padding:0px 2px 2px 0px;';
public function run() {
$this->render('actionButton');
}
}
?>
I got a “500 server internal error”… I activated debug but, is it working in case of internal error ?? often it’s pointing a syntax error somewhere in the code… but here I cannot see where could be the error.
// remove the following lines when in production mode
defined('YII_DEBUG') or define('YII_DEBUG',true);
// specify how many levels of call stack should be shown in each log message
defined('YII_TRACE_LEVEL') or define('YII_TRACE_LEVEL',1);
Where can see log debug message ? is trace level correct ? I never got this working to be honest, is it logging in a file or directly on screen ? though it seemed to me that my index.php was ok to get debug log.
You can check your application log (by default, the file application.log in the runtime directory), the PHP log file and the Web server logs to find the information about it.
If you just throw an exception in your controller, can you see the Yii’s default error page?
Correct me if I’m wrong, but don’t you need to pass the properties to the render method.
public function run() {
$this->render('actionButton');
}
// Should be
public function run() {
$this->render('actionButton', array(
'directToLink' => $this->directToLink,
...
));
}
In this case, [font="Courier New"]directToLink[/font] is a property of the controller class. The view has access to the controller instance via [font="Courier New"]$this[/font], so it is not needed.