Jump to content

Recommended Posts

Posted

How can I get the id of a repeater field from another page?

I want to do something like

if($pages->get(1034)->quotes->id == $i){
		echo "Yes";
	}

Where quotes is the name of the repeater field

Posted

You're checking if the id is the same as $i, but you're in no way looping through all the repeater fields, so this makes no sense in this state. If you try to get a specific repeater field you'd do it like this:

$pages->get(1024)->quotes->eq($i); //Get the $i's repeater field
Posted

Thanks LostKobrakai, I wondered about eq() - at the moment this is giving me an error - Error: Call to a member function eq() on a non-object

Any ideas would be great.

Posted

Strange. eq() should be available, as a repeater should simply return a PageArray, but you could also try get(). It may even be better than eq() as I'm not sure if the PageArray is indexed by position or by id. If that's not working try to check what type of object you're getting from your quotes repeater.

Posted

Quotes is not an object so the error makes sense. However I have double checked and quotes is definitely the correct name of the repeater field. Bit baffled.

Posted

lol, I copied your code and the page id number was different. Feel like a complete (choose appropriate insulting word) - wrong page id - I never noticed! Now eq() works fine. Thanks a lot LostKobrakai :-)

  • Like 1

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