![]() |
|
|||
|
Hi.
How can I render a GD or JpGraph image in a Zend Framework view ? I'd like to do something thike this: public function indexAction() { $im = imagecreatetruecolor ( 300, 200); $black = imagecolorallocate ($im, 0, 0, 0 ); $white = imagecolorallocate ($im, 255, 255, 255 ); imagefilledrectangle ($im,0, 0,399,99 ,$white); imagerectangle ($im,20, 20,250,190 ,$black); header ("Content-type: image/png" ); $this->view->imagen=$im; } Thanks. |
|
|||
|
Yep, pretty close.
You can either add a view with [php] <?php echo $this->imagen; ?> [/php] in it to output the contents of the image, or disable view rendering with [php] $this->_helper->viewRenderer->setNoRender(); [/php] and echo from the controller. or moving everything you have there into the view (leaving the controller empty) would be another (possibly better?) option.
__________________
Brenton Alker PHP Developer - Brisbane, Australia blog.tekerson.com | twitter.com/tekerson | brenton.mp |
|
|||
|
Ok.
Then I try with this controller: public function indexAction() { } And In the script view: <? $im = imagecreatetruecolor ( 300, 200); $black = imagecolorallocate ($im, 0, 0, 0 ); $white = imagecolorallocate ($im, 255, 255, 255 ); imagefilledrectangle ($im,0, 0,399,99 ,$white); imagerectangle ($im,20, 20,250,190 ,$black); header ("Content-type: image/png" ); imagepng ($im); ?> But the browser outputs somethig like �PNG IHDR,�ݽK�IDATx���1� A1����+��q�'�+6P1������D1BL�!�D1BL�!�D 1BL�!�D1BL�!�D1B�sx����?U���Jpe�k�sb "��!&B��b"��!&B��b"��!&B��b"��!&B��b"��!& B��b"��!&B��b"��!&B��b"��!&B��b"��!&B��b" ��!&B��b"��!&B��b"��!&B��b"��!&B��b"��!&B ��b"��!&B��b"��!&B��b"��!&B��b"��!&B��b"� �!&B��b">��� ɬ?��IEND�B`� If I run the view script separately (without Zend framewor) it's Ok. Any suggestions? Thanks. |
|
|||
|
Quote:
If I don't use layout it's ok. I have In my bootstrap $view = Zend_Layout::getMvcInstance()->getView(); $view->doctype('XHTML1_STRICT'); And the layot script is very simple <html> <head> <head> <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" /> <title>Zend Framework Application</title> </head> <body> <?= $this->layout()->content ?> </body> </html> I want to use my layout. What's wrong? |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
| Designed by: Miner Skinz |
Powered by vBulletin® Version 3.8.4 Copyright ©2000 - 2010, Jelsoft Enterprises Ltd. Search Engine Friendly URLs by vBSEO 3.1.0 |
![]() |