Oh no! Where's the JavaScript?
Your Web browser does not have JavaScript enabled or does not support JavaScript. Please enable JavaScript on your Web browser to properly view this Web site, or upgrade to a Web browser that does support JavaScript.
Sign In
Not a member yet? Click here to register.

Adding latest news from a News Cat to Custom Pages

How can I add news from a News Category at the bottom of a Custom Page?

I was looking in the forum but couldn't find anything.

Thx in advance
Can any1 help me with this?
This is really one for the mods site, but here goes anyway.

This will put the latest news item from a specified* news category into a custom page....

CodeDownload  
<?php
echo "<hr>";
echo $locale['global_077'];
$result = dbquery("SELECT * FROM ".DB_NEWS." INNER JOIN ".DB_NEWS_CATS." WHERE news_cat_id = '1' ORDER BY news_datestamp DESC LIMIT 1,1");

if (dbrows($result) != 0) {
   while ($data = dbarray($result)) {
      $itemsubject = trimlink($data['news_subject'], 200);
      echo "".showdate("%d %B %Y", $data['news_datestamp'])."  <img src='".THEME."images/bullet.gif' alt=''> <a href='".BASEDIR."news.php?readmore=".$data['news_id']."' title='".$data['news_subject']."' class='side'>$itemsubject</a><br />\n";
 echo $data['news_extended'];
echo "<hr>";
 }
} else {
   echo "<center>".$locale['global_078']."</center>\n";
}
?>




*: WHERE news_cat_id = '1' - Change the 1 to the news category number you want to the items to be taken from.

If you want to show the snippet instead of the full news item change echo $data['news_extended']; to echo $data['news_news'];

Happy Trails B)
Thanks a lot, i'll give it a try
Great. Thanks a lot

How can I add the titles only though? Or more than 1 news item?

For example the last 5 or 10 news items
What I am trying to do is to make a English page for my website.

I want to add there news from a news category "English".

How can I do this so the news there look the same as in the main page, but only news from this category show.
Can anyone help with this?
Try this:
CodeDownload  
<?php
echo "<hr>";
echo $locale['global_077'];
$result = dbquery("SELECT * FROM ".DB_NEWS." INNER JOIN ".DB_NEWS_CATS." WHERE news_cat_id = '82' ORDER BY news_datestamp DESC LIMIT 1,10");

if (dbrows($result) != 0) {
   while ($data = dbarray($result)) {
      $itemsubject = trimlink($data['news_subject'], 200);
      echo "<br />".showdate("%d %B %Y", $data['news_datestamp'])."  <img src='".THEME."images/bullet.gif' alt=''> <a href='".BASEDIR."news.php?readmore=".$data['news_id']."' title='".$data['news_subject']."' class='side'>$itemsubject</a><br />\n";
echo "<hr>";
 }
} else {
   echo "<center>".$locale['global_078']."</center>\n";
}
?>



This will show the last 10 news items from news cat 1 with subjects only.
Thread Information
Author
Replies
8 posts
Views
2,633 times
Last Post
Last updated on 11 years ago
You can view all discussion threads in this forum.
You cannot set up a bounty in this discussion thread.
You can start a new discussion thread in this forum.
You cannot reply in this discussion thread.
You cannot start on a poll in this forum.
You cannot upload attachments in this forum.
You can download attachments in this forum.
You cannot up or down-vote on the post in this discussion thread.
Users who participated in discussion: bikerbones, HobbyMan, enimal