Jump to content

PDF files as single Pages (Virtual file repository)


Peter Knight
 Share

Recommended Posts

Working on a site at the moment with lots of PDF downloads and was wondering how you handle these?

In my ProcessWire projects so far, each PDF has generally be restricted to a single page. I normally create a field called Files and reference that in any CK Editor links. The problem I realised is that when one of these PDFs needs replacing, my client needs to remember every page where the PDF is referenced.

With this site I'm currently building, I have multiple pages referencing the same PDF(s). In the CK Editor modal for linking files, I can of course choose a different page where the file "lives".

I'm starting to wonder though if I should create a virtual Files directory which would simply be a container page with each sub-page representing and named after a file.

This way, when my editors need to replace a file, they just need to replace and update in a single location.

Any known cons of doing it this way?

  • Like 1
Link to comment
Share on other sites

@Peter,

I might also suggest a simple processModule to create a quick management system for your files. I find that a dedicated admin page for files is easier for users to remember over navigating the page tree.

I think you could probably do the same with lister (Maybe need ListerPro?)

Link to comment
Share on other sites

@Peter,

I think you could probably do the same with lister (Maybe need ListerPro?)

Love ListerPro. Will definitely use it and it would allow me to use columns for last updated, modified by and even short descriptions of files etc

  • Like 2
Link to comment
Share on other sites

@peter

For the title you can specify a pattern to force the pdf extension.

^.*\.pdf$

Hi Martijn

The PDF pages open as PDFs without applying this. Probably because in CK Editor I am linking to a page and then selecting a file attached to that page.

I imagine forcing the PDF extension is mainly used when I am calling a PDF page with an echo statement?

Link to comment
Share on other sites

With the extension, you can see from the page name it is a PDF.
 

// So you can add a class my-pdf to our page PDF's with jQuery for example
$("[href^='/downloads/']").filter(function() {
    return this.href.match(/.*[pdf]$/i);
}).addClass('my-pdf');

 
And when you set a PDF header, browsers even don't know if it's not a real PDF.

header("Content-type:application/pdf");
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...