On Sep 6, 2007, at 2:54 PM, bteeter wrote:
> > I'm developing an app which is a set of business data in a MySQL > backend. One of the views I'd like to provide is a "graph it" view. > Basically I want to use Cake to get data into the Model and jpgraph to > create a graph. > > The code works, and the page correctly works with jpgraph to create an > image. The problem is jpgraph renders an image and returns image > data. Cake is wrapping it in the html template. So the browser barfs > on it, saying something to the effect of: > > Firefox: > > The image "MetricData/graphMetric/1" cannot be displayed, because it > contains errors. > > IE: > > Renders the page header, and a binary chunk of characters that is the > data that makes up the image > > I know I could create a seperate PHP page that accepts all sorts of > parameters, that then makes the calls to jpgraph, so I could do > something like this in my cake view page: > > <img src="imagepage.php? > xaxis=data&yaxis=data&datapoints=1,2,3,4,5,6,7"> > > But that is ugly. I'd rather just have the cake page render as an > image. > > Is there a way to do this? Create your own JPgraph layout (or use the existing, empty, ajax layout) and specify its use in the controller action that generates the non-HTML output. function graphMetric($var) { $this->layout = 'graph'; //or 'ajax' //do stuff } This kind of technique is also really handy if you're serving back XML or JavaScript, because you can place header() calls in your layout. -- John --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Cake PHP" group. To post to this group, send email to cake-php@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---