Jump to content

Recommended Posts

Posted

Rusty newbie here...

I have a template called MeetingEvent, to which I've added a file field to allow uploads of multiple PDFs.
The field is called meeting_event_pdf_attachment.
Users may attach any number of files to this field, and it's set to provide an array of items (for simplicity).
I'm having trouble getting the filename and path out of the supplied data - surely I've forgotten some bit of PHP syntax here.

If I do                 var_dump($page->meeting_event_pdf_attachment);
I get something that looks like this:

object(ProcessWire\Pagefiles)#415 (2) {
  ["count"]=>;
  int(1)
  ["items"]=>;
  array(1) {
    ["accessibility.pdf"]=>;
    string(17) "accessibility.pdf"
  }
}
(In this example, my attached file is called "accessibility.pdf")

                var_dump($page->meeting_event_pdf_attachment->count);
outputs int(1) as expected.

                var_dump($page->meeting_event_pdf_attachment->items);
outputs NULL. 
I was expecting ->items to be an array - it sure looks like one.

I need to be able to walk through "items" and grab the URL for the things listed there, but with it being NULL, I'm kind of perplexed as to how to do that.

Should I be using a repeater instead?

Any advice appreciated.

Posted

That did it - thanks.
$page->meeting_event_pdf_attachment rather than $page->files in my case - just in case anyone else is reading this.
Cheers.

 

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
  • Recently Browsing   0 members

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