Yii Framework Forum: Print page - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

Print page Rate Topic: -----

#1 User is offline   Khan 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 20
  • Joined: 09-September 10

Posted 03 October 2010 - 04:48 PM

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
0

#2 User is offline   junxiong 

  • Advanced Member
  • PipPipPip
  • Yii
  • Group: Members
  • Posts: 541
  • Joined: 21-June 10

Posted 03 October 2010 - 08:50 PM

View PostKhan, on 03 October 2010 - 04:48 PM, said:

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,
                ));

“The most likely way for the world to be destroyed, most experts argue, is by accident. That’s where we come in; we’re computer professionals. We cause accidents.” - Nathaniel Borenstein

Yii Playground : Collaborative demo apps. You can join to improve it too!
My Team's Blog: In Indonesian.
0

#3 User is offline   zaccaria 

  • Elite Member
  • PipPipPipPipPip
  • Yii
  • Group: Members
  • Posts: 2,232
  • Joined: 04-October 09
  • Location:Moscow

Posted 04 October 2010 - 02:37 AM

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
0

#4 User is offline   Raoul 

  • Master Member
  • PipPipPipPip
  • Yii
  • Group: Members
  • Posts: 643
  • Joined: 29-November 08
  • Location:Paris, France

Posted 04 October 2010 - 03:25 AM

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
Posted Image
0

#5 User is offline   Khan 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 20
  • Joined: 09-September 10

Posted 04 October 2010 - 08:41 AM

View Postjunxiong, on 03 October 2010 - 08:50 PM, said:

Maybe, instead using
$this->render('viewpage',array(
			'model'=>$model,
		));

you can use renderPartial
$this->renderPartial('viewpage', array(
                        'model'=>$model,
                ));




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
0

#6 User is offline   Lilt 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 53
  • Joined: 06-July 10

Posted 04 October 2010 - 06:45 PM

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.
0

#7 User is offline   Khan 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 20
  • Joined: 09-September 10

Posted 06 October 2010 - 11:29 AM

View PostLilt, on 04 October 2010 - 06:45 PM, said:

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.
0

#8 User is offline   itmagetan 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 90
  • Joined: 25-February 11

Posted 21 May 2011 - 07:34 AM

Hi..take a look at this cool extension.
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users