Jump to content

Recommended Posts

Posted

What selector string should I use to return pages that have a specific page selected in a Page Fieldtype input? I searched around and tried multiple things, but couldn't find the answer. I really figured this should be easy, so I may totally be overlooking something.

I have pages that can have any number of tags selected (through a Page Fieldtype input). I would like to return a PageArray of pages that have the "Featured" tag selected. (It doesn't have to be the ONLY tag selected.) I attempt to do that with the following code, but it is returning all the pages.

$featuredTag = $pages->get('template=tag, title=Featured');
$featuredPages = $page->children("tags=$featuredTag");

Any idea what I'm doing wrong? Am I totally missing something?

(A little more info, I am using checkboxes to select the tags in the Page Fieldtype input.)

Posted

Looks ok, though I would use "name".

Not sure what's not working. Can you make sure the $featuredTag is really the page returned?

You could try a different version.

$featuredTag = $pages->get('/tags/featured/'); // use the path
$featuredPages = $page->children->find("tags=$featuredTag");

What does it?

Posted

D'oh! Totally my mistake. Had something else wrong with my code. Ryan - can we delete this topic?

Posted

Yup - $featuredTag returned just fine. It was a mistake in my code in a loop below it. Silly me.

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