ferahl Posted November 19, 2012 Share Posted November 19, 2012 Hi, I am printing out some "post" page children on my home page. These "post" pages have a field called "category" which is a fixed list of pages - "News/Events/Projects". My code looks like this: $posts = $pages->find("parent=/posts/, limit=6"); foreach($posts as $post) { // render out } The field name is "category" but when I do $post->category it returns a page ID like 1014, if I do: $pages->get($post->category)->title This returns "Home" instead of the category which is one of "News/Events/Projects". What am I doing wrong? Thanks Link to comment Share on other sites More sharing options...
Soma Posted November 19, 2012 Share Posted November 19, 2012 If it's a single page field $post->category->title If multiple, it's an array of pages $post->category->first()->title If think your example would have to be $pages->get($post->category->id)->title But no need to get the page as you already got it (or the bunch of them as pagearray) 3 Link to comment Share on other sites More sharing options...
ferahl Posted November 19, 2012 Author Share Posted November 19, 2012 If it's a single page field $post->category->title If multiple, it's an array of pages $post->category->first()->title If think your example would have to be $pages->get($post->category->id)->title But no need to get the page as you already got it (or the bunch of them as pagearray) Damn pretty obvious! $post->category->first()->title worked thanks a lot! Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now