Jump to content

Matching page object fields with multiple pages


PHPSpert
 Share

Recommended Posts

Trying to select pages based on the relation of the current page's children.

I'm creating a magazine site. There are topics and sub topics. Each article can have more than one topic.

For example:

City Living (topic)

- Housing (sub)

- Transportation (sub)

- Places to Shop (sub)

- etc.

Articles

- Article 1 topic of Housing

- Article 2 topic of Places to Shop

- Article 3 topic of Transportation

In the template for the topic I want to list all of the articles in the sub topics.

I tried doing this: $pages->get("template=topic, sort=-created, limit=10, topic=".$page->children()); but it doesn't seem to work and throws an error.

Is there a simple way of doing this?

BTW, articles are just referenced by the page field and not children of the topics and sub-topics.

Link to comment
Share on other sites

On the admin UI side, what are you using for selection of topics and subtopics? What I'm trying to determine is if topics and subtopics are separate fields, or if you've combined them into one and are using something like a PageListSelect? Your answer to this would help to determine if you are using the right fields on your selector.

In the template for the topic I want to list all of the articles in the sub topics.

I think that Soma's example should work. Your example won't work because it's using $pages->get() rather than $pages->find(), so it would only return 1 page. Though it's still a valid API call so I wouldn't expect it to return an error: what is the error?

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