gnome Posted November 27, 2012 Share Posted November 27, 2012 I have a news articles list displayed: $articles = $pages->find("template=template-news, sort=-newsDate, limit=5"); Now I need to have a new page which shows some (but not all) of the news articles. What would be the best/easiest way to achieve this? Thanks! Link to comment Share on other sites More sharing options...
Exceptionz Project Posted November 27, 2012 Share Posted November 27, 2012 Did you read this thread? http://processwire.com/talk/topic/22-how-to-build-a-news-page/ Link to comment Share on other sites More sharing options...
diogo Posted November 27, 2012 Share Posted November 27, 2012 Depends on what news you want to appear there. Random? Latest highlights? For latest highlights for instance, you could put a "highlight" checkbox on the news template, and call the last five like this: $highlights = $pages->find("template=template-news, sort=-newsDate, highlight=1, limit=5"); Link to comment Share on other sites More sharing options...
onjegolders Posted November 27, 2012 Share Posted November 27, 2012 Gnome, sounds like you just need another template with exactly the same code as you have above but change the "find" selectors. Which pages do you want to include/exclude? If you can't filter them in your "find" method, you can use an "if statement". Eg: $articles = $pages->find("template=template-news, sort=-newsDate, limit=5"); foreach ($articles as $article) { if ($article->my_field != "") { // show page stuff } } Link to comment Share on other sites More sharing options...
gnome Posted November 28, 2012 Author Share Posted November 28, 2012 I think this $highlights = $pages->find("template=template-news, sort=-newsDate, highlight=1, limit=5"); is what I need. Thanks to all! 1 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