Author Topic: Front Page News  (Read 3865 times)

Offline pszilard

  • Posts: 75
  • Gender: Male
    • RemekTek
Front Page News
« on: December 12, 2007, 09:34:42 PM »
I have a dedicated News Page, which works fine.

I would like to be able to pickup the latest "x" number news items to show on my Home Page. Is this easily doable? I tried searching the forums but could find an answer, but if this is already discussed somewhere, please give me a pointer. Ta.
Paul Szilard
WB user since Dec 2007:
http://www.remektek.com.au/wb
http://photos.remektek.com.au/ for my photo portfolio

Offline albatros

  • Posts: 696
  • Gender: Male
    • http://www.willingen-ferienhaus.de
Re: Front Page News
« Reply #1 on: December 12, 2007, 10:55:39 PM »
Hi,

yes it is possible. Have a look on "any news" http://addons.WebsiteBaker.org/pages/modules/code-snippets.php

hth

Uwe
أنا لست إرهابيا. ليس لدى أي ورشة عمل القنبلة في الطابق السفلي. ليس لدى أي مرض الجمرة الخبيثة أيضا. أريد شراء لا مادة الريسين. أنا سوف ابدأ السفر إلى الولايات المتحدة الأمريكية

Offline stinkywinky

  • Posts: 15
Re: Front Page News
« Reply #2 on: December 13, 2007, 07:39:46 AM »
Another easy option is to put the next code inside your template:

Code: [Select]

<ul> 


<!-- NEWS READER -->

<?php
$group 
3// Specify the Group(id) you want to read the news from

global $database;

$query "SELECT *, DATE_FORMAT(FROM_UNIXTIME(posted_when), &#39;%d/%m/%Y&#39;) AS datum_nl
FROM "
.TABLE_PREFIX."mod_news_posts
WHERE group_id = 
$group
ORDER BY post_id
DESC LIMIT 0,3;"

// This limits the results to max 3, so if you want it to be 10, make it LIMIT 0, 10.
// The first number defines the starting point, and the second the max/end of the results

$content mysql_query($query) or die (mysql_error() .&#39;<BR>&#39;. $query);

while ($data mysql_fetch_array($content))

{
  
$id $data[post_id];
  
$link $data[link];


  
$query_comments $database->query("SELECT title,comment,commented_when,commented_by FROM ".TABLE_PREFIX."mod_news_comments WHERE post_id = &#39;".$id."&#39;");
  
$comments_count=$query_comments->numRows();

?>


<li><? echo $data[datum_nl];  ?>-<a href="<?php echo WB_URL.PAGES_DIRECTORY.$link.PAGE_EXTENSION;?>"><?php echo $data[title]; ?></a>
<br /><a class="nieuws" href="<?php echo WB_URL.PAGES_DIRECTORY.$link.PAGE_EXTENSION;?>">lees het volledige bericht</a>
</li>


<?php
}
?>


<!-- END NEWS READER -->


Offline pszilard

  • Posts: 75
  • Gender: Male
    • RemekTek
Re: Front Page News
« Reply #3 on: December 15, 2007, 10:16:34 AM »
Stinkywinky, how do I use this code? I tried inserting it into a Code section, but it wouldn't save. I also tried insert it into a WYSYWIG as Source and that didn't work either.
Paul Szilard
WB user since Dec 2007:
http://www.remektek.com.au/wb
http://photos.remektek.com.au/ for my photo portfolio

Offline stinkywinky

  • Posts: 15
Re: Front Page News
« Reply #4 on: December 15, 2007, 04:27:26 PM »
Just put the code inside your template!

Offline marathoner

  • Posts: 495
Re: Front Page News
« Reply #5 on: December 15, 2007, 11:24:55 PM »
Be aware that if you put this into your template that is will appear on every page and not just your front page...unless you use logic that only includes it if $pageid =0 (or whatever your front page is). I would prefer using Any News snippet (as albatros mentioned to you) and including it into a section on whatever page I want it to include it.

Offline Hans

  • Posts: 912
  • Gender: Male
Re: Front Page News
« Reply #6 on: December 16, 2007, 07:44:29 AM »
You could also use two templates, one with the code for the frontpage, an one without the code for pages  without news.
Hans
Hans - Nijmegen - The Netherlands

Offline pszilard

  • Posts: 75
  • Gender: Male
    • RemekTek
Re: Front Page News
« Reply #7 on: January 03, 2008, 04:56:38 AM »
I got it working by creating a Code Section with "display_news_items(4,20,150,0);" inside it.

Thanks for the pointers.
Paul Szilard
WB user since Dec 2007:
http://www.remektek.com.au/wb
http://photos.remektek.com.au/ for my photo portfolio