Hi.. i can't figure this out and not sure if it's actually possible.
On my index page i'm trying to have just 1 news post (which is truncated with a readmore link..) and then a list of headlines with dates on the right.
I guess i just use the news loop for the headline list - how do i limit that list to say..the 5 most recent?
And then for the news article.. how do i just display the latest one?
Remember this is all on the same page. I tried using 2 news loops and they conflicted.
Thanks for any help!!
Comments
I've looked at the template-functions page and have found getLatestNews().
I don't understand how i impliment it though. I tried this but it just gave me a bunch of syntax errors.
<?php array getLatestNews( [int $number = 5], [string $option = 'none'], [string $category = ''] ) ?>
However, is there a way to get it to only display news? It seems to be displaying both news and album updates. I figure i could just define a category to keep it to news, but i need multiple news categories so that won't work. Is there a way to define a type of news?
this is my line so far:
<?php printLatestNews($number='1'); ?>
Now i've got my line:
<?php printLatestNews($number='1', $option='none'); ?>
How do i style the individual items that make up that post? So like, not have it in a UL... style the link header.. etc.
Is it actually possible without hardcoding it into template-functions.php?
1) There are css classes attached you can style directly.
2) Use the `getLatestNews()` to write your own custom output function (basically all functions have a get equivalent for that reason). You will of course need php knowledge to manage that.
<?php getLatestNews(1,none);
<h2> printNewsTitleLink(); </h2><span>printNewsDate(); </span>
<p> printNewsContent(); printNewsReadMoreLink(); </p>
?>
<?php
$latest = getLatestNews(1,none);
foreach($latest as $item) {
$title = htmlspecialchars(get_language_string($item['title']));
$link = getNewsURL($item['titlelink']);
$content = strip_tags(get_language_string($item['content']));
echo "<h3>".htmlspecialchars($title)."</h3>\n";
echo "<p>".htmlspecialchars($content)."</p>\n";
}?>