Welcome, Guest. Please login or register.
Did you miss your activation email?
May 26, 2012, 07:02:35 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.
155550 Posts in 21714 Topics by 7737 Members
Latest Member: gx-world
* Home Help Search Login Register
Pages: [1]   Go Down
Print
Author Topic: "10 last posts" module ?  (Read 1002 times)
DrunkMoose

Offline Offline

Posts: 53


« on: January 12, 2006, 01:48:00 AM »

Hey guys,

Any of you ever saw a module that displays "x" last posts (from whatever post module) with their "short" version on the same page ? If not, is there easy WB built-in functions that could do that ?

Thanks.

EDIT: I think this post would be more suitable in "Code snippets" I beleive... Cheesy


« Last Edit: January 12, 2006, 01:58:48 AM by DrunkMoose » Logged
DrunkMoose

Offline Offline

Posts: 53


« Reply #1 on: January 12, 2006, 06:13:21 AM »

Woah, that was simple, with the "code" module.

Here's what I did:

Code:
print "<style type=\"text/css\">\n.post_title, .post_date { border-bottom: 1px solid #DDDDDD; }\n.post_title { font-weight: bold; font-size: 12px; color: #000000; }\n.post_date { text-align: right; font-weight: bold; }\n.post_short { text-align: justify; padding-bottom: 5px; }\n</style>\n<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" width=\"100%\">\n";

$database = new database;
$query = "SELECT content_short, link, posted_when, title FROM ".TABLE_PREFIX."mod_news_posts ORDER BY posted_when DESC LIMIT 0,10";
$res = $database->query($query);
while ($post_info = $res->fetchRow())
{
$content_short = $post_info[0];
$LINK = WB_URL."/pages".$post_info[1].PAGE_EXTENSION;
$TITLE = $post_info[3];
$TIME = date("g:i", $post_info[2]);
$DATE = date("F d Y", $post_info[2]);

print "<tr class=\"post_top\">\n";
print "<td class=\"post_title\"><a href=\"$LINK\">$TITLE</a></td>\n";
print "<td class=\"post_date\">$DATE, $TIME</td>\n";
print "</tr>\n";
print "<tr>\n";
print "<td class=\"post_short\" colspan=\"2\">\n";
print "$content_short";
print "<a href=\"$LINK\">Read more...</a>\n";
print "</td>\n";
print "</tr>\n";
}

If you need to tune the date/time, look here www.php.net/date You might also need to tune the link path too

« Last Edit: January 12, 2006, 06:17:39 AM by DrunkMoose » Logged
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!