Jump to content

Related Pages


gnome
 Share

Recommended Posts

I'm not sure I understand your question completely, but you could use the page field for choosing files by having one file per page.

You can do this by creating a field of the type "file" (let's name it "myFile"), and a template with only this field besides "title". Than, create a page "files", and the pages that use this new template as children of it. Now you can create a field of the type "page" (let's name it "myFiles") and choose the page "files" as the "Parent of selectable page(s)" on the input tab. To display the files chosen for a page you just have to do in the page template:

foreach($page->myFile->myFiles as $f) echo $f->url;
Link to comment
Share on other sites

Thanks diogo. I think maybe I've confused things.

What I'm trying to achieve is a page where I can add PDFs to a page. Each PDF would belong to a category. Then I would loop through and show

Category Name

PDF 1

PDF 2

PDF 3

Is this possible?

Thanks!

Link to comment
Share on other sites

Gnome,

To simplify:

Would your files would each live on their own page, under a parent "Files"?

Eg:

Home

About

Contact

Files

-- File 1

-- File 2

Or do you want to be able to have "collections" of files

eg:

Home

About

Contact

Files

-- Brochures (can contain multiple files)

-- Instructions (can contain multiple files)

Do you then want to be able to link another page to these files or files collections? Or is it more simple and you just want a page where you display all your files under their respective heading (Brochures, Instructions)

Sorry, just hard to understand exactly what you want to achieve.

Link to comment
Share on other sites

Hi Gnome

If you want it exactly like that, set up 3 templates in the backend (files, file_category and file_page)

and make 1 template file (files.php)

In your admin, make a Files page with template "files" then as children make Brochures and Instructions (file_category template) and then underneath these make a page for each file / or each collection of files (file_page)

Eg:

Home

About

Contact

Files

-- Brochures

---- Brochure 1

---- Brochure 2

---- Brochure Collection 1

-- Instructions

---- Instructions 1

---- Instructions 2

---- Instructions Collection 1

Then in your files.php file

<?php include("./header.inc"); ?>

<?php

$file_categories = $page->children();

foreach ($file_categories as $category) { ?>

<h3><?php echo $category->title; ?></h3>

<ul>

<?php foreach ($category->children() as $file_pages) {

foreach ($file_pages->files as $file) { ?>

<li>
<a href="<?php echo $file->url; ?>"><?php echo $file->description; ?></a>
</li>

<?php }

} ?>

</ul>

<?php }

?>

<?php include("./footer.inc"); ?>

Note that there may be more efficient ways of doing this, Brochures and Instructions could be there own main pages and in your template file you could find all pages with the "file_page" template and loop through the files but this way has it set up exactly how you want I think.

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

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...