I wanted to just render the page depending on how many times they wanted it to be printed, and have a central place to control the page breaks. Options to have the same header and footer but different content on each page, like invoices. I managed to do it with a widget In the end. Not sure it’s the best way. But managed to do it. I started widget before I started this approach but I couldn’t get the bootstrap CSS to work with bootstrap->register. But I found if I put bootstrap->register in my widget init it work.
You should read and post the error that occurs on creating the Printer component:
Missing argument 1 for Printer::printer(), …?
The solution:
The classname of the behavior should be another than the method you call: for example ‘PrinterBehavior’.
class PrinterBehavior extends CBehavior
{
public function printer($data)
{
$this->owner->render("index"); //better performance: $this->getOwner()->
}
}
class TestController extends Controller
{
public function behaviors()
{
return array(
'printerBehavior' => array(
'class' => 'PrinterBehavior'
)
);
}
...
public function actionIndex()
{
$this->printer(array());
//$this->render('index');
}
You are right! Finally. Must have been my naming of the behaviour. Was my first one I have tried. Is there anyway of using a layout and view file that is stored in my extension relative to the behaviour?