Jump to content

News Categories


gnome
 Share

Recommended Posts

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

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

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

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