Jump to content

Recommended Posts

Posted

Hi folks,

I use the Page field quite often to cross reference data on the sites that I build and they are super useful, but I have a question regarding doing the same thing but with a repeater field? I know a lot of you know might think that perhaps I am using the repeater field wrongly and that the data should in fact be pages but I believe in this case that the repeater field is the best option.

I have a Publications section on my site, which include image and title only, for each. I had thought about making each Publication a 'page' but then all you have on each page to edit is an image and thought this was maybe a bit clunky to do and a repeater would be better? So, if I make Publications a repeater... can I grab a specific 'field' from the repeater in a Page-like field? So, on another section, say Projects, I would be able to link a specific Publication to a Project via a dropdown field. You know?

Let me know if you think there's a better way of doing this... it might be that if I ever need to cross reference another piece of data (an entry in the CMS) then it needs to be part of a 'page' and then easily selectable via a Page Field.

Thanks!
R

Posted

Also, see attached. Is there a way to do the following but have each 'entry' within the year selectable via a Page field or similar? Or would each 'exhibition' need to be a page? It's only text so seems a little weird to do it this way.

5vcgShu.png

Posted

Hi Richard. Guess what? The repeater rows ARE pages :)  They are stored under the Admin area in the page tree. So they could technically be selected in a page field, but I'm not sure how the titles would be handled or how you would select for all pages if the repeater appears on multiple pages. It would probably be a bit clunky, but you might be able to get it to work they way you want if you play around with it.

I think the better way to go would be using a PageTable field, and then hiding the page list somewhere out of the way in the page tree. You would have more control that way. But then you'd have to use the modal windows for updating values, which may not be what you want.

EDIT: Since you can specify a field other than the title to be visible in the Page select input and all of the repeater pages that use the same repeater field are (I think) stored together, maybe repeaters would be the more elegant solution for this after all. Just keep in mind that "plain old pages" are always the more flexible and scalable option if your needs change down the road. 

  • Like 1
Posted

Thanks for the reply!

Are you sure they are? So, for example, how could I use the 'Custom selector to find selectable pages' to grab a repeater? You see what I mean?

Posted

They are pages. Look for them under "Repeaters" inside the admin page in the tree.

Repeater pages are under a page with the name "for-page-1234" (1234 is the ID of the page that holds the repeater field) under a page named "for-field-123" (being 123 the id of the repeater field. You can see it o  the URL when editing the field). This means that you can easily get all pages from a repeater field in a page by using the selector:

$pages->find("parent=/processwire/repeaters/for-field-123/for-page-1234")

Or even construct that selector dynamically when needed:

$pages->find("parent=/processwire/repeaters/for-field-130/for-page-{$page->id}")
  • Like 5
Posted

Ah right, yes thanks this makes sense. In the 'Custom selector to find selectable pages' field, for a PageField, I have put:

parent=/home/repeaters/for-field-112/

but it returns nothing... is this the actual path to admin repeaters?

Posted

You don't need "home" and you need the name of the "Admin" page in it's place. By default, the name of the Admin page is "processwire" so you would want:

parent=/processwire/repeaters/for-field-112/

  • Like 2
Posted

Thanks, guys. This all works great! And I can choose the label to be the title field within the repeater... ALL GOOD!

  • Like 1
Posted

Thanks for this LostKobrakai. So if I replaced the following, in the 'Custom selector to find selectable pages'

parent=/login/repeaters/for-field-144/for-page-1033/

for

template=practice_publication

it not longer works...  should it? Or have I got the wrong end of the stick...

Posted

Thanks, LostKobrakai but it still doesn't seem to work; are you sure it's template=repeater_name?

template=practice_publication, include=hidden
Posted

You can check this by enabling "view system templates" in the template overview. This should show those automatically created templates.

Edit: you need to literally add "repeater_" in front of thr name.

  • Like 2
Posted

Amazing... thanks! I didn't think you meant 'repeater_' but by enabling the View System Templates it makes sense now :) A great solution, thoughts!

  • 5 years later...
Posted

I ran into the same problem. The selector as mentioned by LostKobrakai works fine for me as admin. But for other users the field appears always empty in Processwire.

What permission do i need to give to the user-role to make it work for them? And how do i do that?

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