Jump to content

Recommended Posts

Posted

On this topic:  I've asked (and answered myself) how to get the field name on a page used for uploading files. 

Now, what if I'm using a repeater field to upload files? How can I get the name of the page of the item uploaded to?

I'm using a InputfieldFile::fileAdded hook and even if I try to get the $event->arguments(0)->page->name I get the internal name of the repeater page, not the name of the page where the field is. $event->arguments(0)->page->parent->name is almost what I need because I get the name "for-page-xxxx" and xxxx is the id of the page where the field belongs. 

Is there any easier way to reference this page name without, I don't know, parse this string to extract the numeric id and then search for the page name?

Posted

Nico,

I just wanted to know if there was a better way (through referencing?) than using: 

$p = $event->arguments(0)->page->parent->name;
$page = wire(pages)->get("name={$p}")->title;

to get the name of the page (not that there's anything wrong with that).

Ok, the reason I need the to upload a field with a repeater with file fields inside is because I need to add a description of those files that must be translated in 5 languages.  That was the fastest way I've found to achieve this.

  • Like 1
Posted

interobang,

That's it. Thanks. 

this is all I need now: 

$p = $event->arguments(0)->page->getForpage()->title;

I know we have available the very useful cheatsheet provided by Soma but is there further documentation for the PW API other than that provided here

  • Like 1
Posted

I know we have available the very useful cheatsheet provided by Soma but is there further documentation for the PW API other than that provided here

If I can't find it on the cheatsheet, I usually directly look into the well documented sourcecode or google search the forum here. 

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
×
×
  • Create New...