Print page

Hi,

I’m trying to achieve this task…

I have a product listview from where if a user click on ‘Print Product’ for any particular product it takes product ID to the controller and find out that product by ID and return their details to View form which is doing fine now but in View I don’t need to display Header and Footer graphics/values as I design my own View which is going to Print on printer.

Any Idea how to avoid not to display Header and Footer details on Printing Page.

Maybe there is another way to handle this simple task as me learning Yii framework.

I would appreciate and early response.

Khan

Maybe, instead using


$this->render('viewpage',array(

			'model'=>$model,

		));

you can use renderPartial


$this->renderPartial('viewpage', array(

                        'model'=>$model,

                ));

You can also create a new templae in view/template folders, like print.php and use this for printing.

You can start editing the main.php and removing all that is not needed

Another possible solution would be to create a CSS only for the print.

In this CSS, you can hide footer, header etc …




<link rel="stylesheet" href="print.css" type="text/css" media="print" />



hope it helps

Thanks for all you guys and really appreciated your replies to it and it did works by applying junxiong below codes


$this->renderPartial('viewpage', array(

                        'model'=>$model,

                ));

Have a good day,

Khan

Note that renderPartial won’t include any headers or javascript, meaning any graphical Javascript code won’t be run (no Cufon, for example). The ‘correct’ way is probably to use the print-specific CSS to hide the bits of the page you don’t like when printing, but YMMV.

Hi Lilt, thanks for your comments as I wasn’t know about that as well but my printing form doesn’t have any such Graphicas or JavaScript to load on printing page as got few CSS work which I already defined on that page.

Have a good day.

Hi…take a look at this cool extension.