You don't need the controller serve PDFs unless you have some reason
to keep them inaccessible to casual browsers and want to use some kind
of authorisation. In that case, you'd want to look at MediaView.
Otherwise, just let Apache serve it as any other file. Hence, you put
it under webroot. Anything that's under that directory is accessible
with a direct link--images, javascript, CSS files, etc. So, you can
create whatever directory structure you want in there if you have
reason to.

Perhaps the confusion stems from the fact that the HtmlHelper has a
method to create image links. But, if you look carefully, you'll see
that the URL points directly to the image file under webroot, not a
controller. I think that maybe the only reason $html->image() exists
is because too many people were becoming confused by Cake's mysterious
DOCUMENT_ROOT shuffling (I was) that they were messing up their img
links.

To answer your other question about the views dir, all those files in
there are basically templates for displaying a controller's output.
That's not the webroot, but simply a convenient directory in which to
store template files. What mscdex was suggesting is, if you happened
to have a controller action where you wanted to redirect the request
to some PDF file, you'd use the public URL as the param to redirect().
Something like

$this->redirect('/fitness_lab/forms/health_questionnaire.pdf');

But I'm pretty sure that's not what you're after here. Just leave the
controller out of it.

On Mon, Feb 9, 2009 at 8:01 PM, justclint <[email protected]> wrote:
>
> Thanks mscdex. Your 2nd suggestion is exactly what Im trying to do.
> Brian suggested adding the directory to webroot which works as
> intended.
>
> However, I did have the pdfs in a the views folder and I tried the
> redirect() but I run into the same problem trying to define what the
> controller and action would be for a pdf file.
>
> How would I use this redirect to show the pdf file?
>
> Thanks!
>
> justclint
>
>
> On Feb 8, 10:08 pm, mscdex <[email protected]> wrote:
>> Generally if you are manually rendering a view, you should do: 
>> $this->autoRender = false;
>>
>> If you are trying to get the PDF to show up instead of the controller
>> action's view, you could try doing a $this->redirect() as documented
>> here:http://book.cakephp.org/view/425/redirect
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to