Welcome, Guest. Please login or register.
Did you miss your activation email?
May 25, 2012, 01:07:27 PM

Login with username, password and session length
Search:     Advanced search
Interested in joining the WebsiteBaker team?
For more Information read here or on our new website.
155504 Posts in 21710 Topics by 7736 Members
Latest Member: deenangle
* Home Help Search Login Register
Pages: [1]   Go Down
Print
Author Topic: News module help  (Read 312 times)
andyeswecan

Offline Offline

Posts: 6


« on: June 03, 2009, 03:48:17 PM »

hi...

i'm a bit of a newbie to website baker and have taken on a site built by someone else.

I have the following php in my template and basically need to amend it so that i can filter results by group_id.

**

<?php
ob_start();     // start output buffer
global $database;
$query = "SELECT post_id,title,content_short,group_id,link FROM ".TABLE_PREFIX."mod_news_posts ORDER BY position DESC LIMIT 0, 5;";
$error = mysql_error();
if (!$result = mysql_query($query)) {
print "$error";
exit;
}
while($data = mysql_fetch_object($result)){
$title = $data->title;
$id = $data->post_id;
$link = $data->link;
$short = $data->content_short;
echo '<p><a href="'.WB_URL.'/pages/'.$link.PAGE_EXTENSION.'" class="latestnews">'.$title.'</a></p><p>'.$short.'</p><hr/>';
}
$foo=ob_get_contents();    // put outputbuffer in $foo
ob_end_clean();             // clear outputbuffer
if ($foo<>"") {  // some code to execute cause there is some block

echo '<h3 class="latestnewsheader">Latest News</h3>';
echo $foo;

} else { // some code for no info
}
?>

**


any help would be greatly appreciated. it's probably easy for someone with more experience
thanks
Andrew

Logged
kweitzel
Forum administrator
*****
Offline Offline

Posts: 6975


WWW
« Reply #1 on: June 03, 2009, 05:57:45 PM »

replace this code with the anynews snippet (look on the add-on repository). There you have moer options and don't need to have the code in the template.

cheers

Klaus
Logged

WebsiteBaker Org e.V. - for WebsiteBaker

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!