Jump to content

Get page from repeater


nabo
 Share

Recommended Posts

Hi

$exhibitions = new PageArray();

  foreach ($events as $event) {
    foreach ($event->event_exhibition as $exhibition) {
      $exhibitions->append($exhibition);
    }
  }

  $exhibitions->sort("event_first_date"); 

each event use repeaters for exhibitions. I need to print all exhibitions but at the same time I need the title of the event...
I tried $exhibition->parent->title.... but it's not working :(

Link to comment
Share on other sites

Sorry, maybe I was not too clear...

$exhibitions = new PageArray();

foreach ($events as $event) {
	foreach ($event->event_exhibition as $exhibition) {
		$exhibitions->append($exhibition);
	}
}

$exhibitions->sort("event_first_date");

foreach ($exhibitions as $exhibition) {
	echo $exhibition->parent->title;
}

This change 

$exhibitions->append($exhibition->getForpage());

doesn't work. I think "parent" works for page but not for repeater :(

Link to comment
Share on other sites

Of course it works. getForpage() returns the page where the repeater item lives. your code snippet was not clear to me, so you might use it differently, but using getForpage() is the key.

You didn't provide any information of what your code does, which variables are what kind of data (pages, repeater items) etc.; Also you didn't provide information what you did exactly (where you placed my code) and what did not work. "doesn't work" is not a lot of information...

10 minutes ago, nabo said:

I think "parent" works for page but not for repeater :(

Yes, that's correct and totally makes sense, since it is a repeater item and not a page with a parent page. ;)

  • Like 2
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...