Jump to content

PDF Downloads Sidebar


gnome
 Share

Recommended Posts

Hi all

I am very new to ProcessWire, but have managed to create a content managed site in super quick time! :)

I currently have 2 templates, home and content - that's all I've needed!

But now I need to add a new column on the right of my pages that will hold a list of PDF downloads. The list of downloads will be different on each page - some will have a few, some will have none.

Each item in the list needs a name, thumbnail image, and document to link to.

I was tempted to create a new template for each, but I don't think that's the way to go. Would I do this like a list of news articles? But then I don't know how to specify which 'articles' appear on which page?

Any pointers would be greatly appreciated!

Link to comment
Share on other sites

It the files differ per page you can create a repeater field with the fields you mentioned above.

If you want the files to be 'selectable', so you can use the same file on multiple pages a seperate tree with it's own template would be my way to go. You can use the Page fieldtype to connect the page/sidebar to the download. Basicly you use a page as a download. This might seem strange, but it's a bit how ProcessWire works. Pages are not always pages in the context of the web, but more as objects or nodes.

  • Like 1
Link to comment
Share on other sites

To continue from where Arjen left - I would probably create two new templates:

files & file

Files would get only one (hidden) page (/files/) and maybe not template file at all. No need for other fields than title either. Then file-template would get file-field, image-field for thumbnail and maybe textfield for extended summary (if needed).

Then the "special glue" is to create page-field called: "files". Allow it to choose multiple pages and give it nice inputfield (asmSelect probably best here). Then configure it to have pages under your /files/ page. Then add this files-field to your "content" template and you are ready to go!

On template level it would work like this (content.php):

// Loop the pages you have chosen in your files-page reference field
foreach($page->files as $p) {
// And then echo the stuff those pages have in their fields
echo "<a href='{$p->file->url}'>$p->title</a>";
}

PS: The files template is not necessary at all, but it will allow you to set /files/ page to have children with only file-template. This will keep your content clean in the long run, and also it will hold a nice place if you want to extend and offer some "file search" or something like that.

  • Like 1
Link to comment
Share on other sites

Great additions.

I often also create the page Files in a seperate page called /downloads/files/. This way you can use the /downloads/ page to hold multiple stuff like /downloads/categories/ or /downloads/tags/. I then use the /downloads/ page as a passthrough if the files need to be non accessable from the outside. But this doesn't seem to be necessary in this case ;)

Link to comment
Share on other sites

arjen, apeisa - thank-you.

I have used a repeater field and it's just what I need. One problem I have though - I've defined a 'file' field as part of my repeater, but when I try to add a PDF document it says that .pdf is not a valid file extension. Is it not possible to have PDF or do I need a different field type?

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