Welcome, Guest. Please login or register.
Did you miss your activation email?
May 27, 2012, 05:20:17 AM

Login with username, password and session length
Search:     Advanced search
Wollen Sie dem WebsiteBaker Team beitreten?
Nähere Informationen finden Sie unter hier und auf unserer neuen Webseite.
155555 Posts in 21715 Topics by 7737 Members
Latest Member: gx-world
* Home Help Search Login Register
Pages: [1]   Go Down
Print
Author Topic: Front Page News  (Read 1273 times)
pszilard

Offline Offline

Posts: 73


WWW
« 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.
Logged

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

Offline Offline

Posts: 674


WWW
« 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
Logged
stinkywinky

Offline Offline

Posts: 11


« Reply #2 on: December 13, 2007, 07:39:46 AM »

Another easy option is to put the next code inside your template:

Code:

<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), '%d/%m/%Y') 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() .'<BR>'$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 = '".$id."'");
  
$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 -->

Logged
pszilard

Offline Offline

Posts: 73


WWW
« 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.
Logged

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

Offline Offline

Posts: 11


« Reply #4 on: December 15, 2007, 04:27:26 PM »

Just put the code inside your template!
Logged
marathoner

Offline Offline

Posts: 495


« 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.
Logged
Hans

Offline Offline

Posts: 565


« 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
Logged

Hans - Nijmegen - The Netherlands
pszilard

Offline Offline

Posts: 73


WWW
« 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.
Logged

Paul Szilard
WB user since Dec 2007:
http://www.remektek.com.au/wb
http://photos.remektek.com.au/ for my photo portfolio
Pages: [1]   Go Up
Print
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines Valid XHTML 1.0! Valid CSS!