Jump to content

Select pages using specific template


JerryDi
 Share

Recommended Posts

35 minutes ago, ngrmm said:

What is the output for this:

 echo gettype($championship->winner_name);

You should try this. ?

And this:

echo("<pre>" . print_r($championship->winner_name, true) . "</pre>");
exit();

And maybe show the configuration of the PageReference field.

I have no idea what is going on. ?

Link to comment
Share on other sites

Have tried this:
echo("<pre>" . print_r($championship->winner_name, true) . "</pre>");
exit();

and the output is as attached

When I tried this: echo gettype($championship->winner_name); I just got the word "object".

So I tried echo gettype($championship->winner_name->title);

and this produced "NULL"

output1.JPG

Link to comment
Share on other sites

@JerryDi you already tried this?

3 hours ago, ngrmm said:

Then maybe winner_name is a multipagefield and you try this:
 

$playerChampionships = $pages->find("template=Championship_results, winner_home_club={$page->id}");

foreach($playerChampionships as $championship) {
	echo "<li><a href='$championship->url'> $championship->title - {$championship->winner_name->first->title}</a></li>";
}

 

 

 

Link to comment
Share on other sites

6 minutes ago, ngrmm said:

you already tried this?

That's probably the issue. print_r output shows it's a PageArray, so we can't call PageArray->title.

Instead of editing the code it's better to edit the PageReference configuration to set it to a single page and choose a single selection mode (a competition has only one winner):

image.png.fb2f7ff2850f8fa8fcd571c85499a62d.png

 

image.png.5b3aef53acc35850d6f496bcf1648f50.png

Link to comment
Share on other sites

2 minutes ago, JerryDi said:

Actually some competitions are for pairs, so multiple is required

thanks

Just FYI for those pages you would need to loop through $championship->winner_name. So you better loop always

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