gnome Posted November 27, 2012 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!
Exceptionz Project Posted November 27, 2012 Posted November 27, 2012 Did you read this thread? http://processwire.com/talk/topic/22-how-to-build-a-news-page/
diogo Posted November 27, 2012 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");
onjegolders Posted November 27, 2012 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 } }
gnome Posted November 28, 2012 Author 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
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