Advanced Search  :  Site Statistics  :  Directory  :  Web Resources  :  Forum  
    Plugins for Geeklog Geeklog Plugins    
 Welcome to Plugins for Geeklog
 Saturday, May 17 2008 @ 07:03 AM EDT

Latest Stories in a Static Page

   
GeekLogI decided to put the titles for the latest stories in the static page centerblock on one of my sites. Here is the code to do this, just place it in a static page, set the centerblock option, set the execute php option to 'execute PHP (return)' and pretty it up however you want. It will display the last date and titles of the last 15 (or whatever you set the $numstories variable to) stories.

Anyway here is the code ...



$numstories = 15;
$sql = "SELECT *,unix_timestamp(date) AS day";
$sql .= " FROM {$_TABLES['stories']}";
$sql .= " WHERE (date <= NOW()) AND (draft_flag = 0)";
$sql .= " AND (";
if (!empty ($_USER['uid'])) {
    $groupList = '';
    foreach ($_GROUPS as $grp) {
        $groupList .= $grp . ',';
    }
    $groupList = substr ($groupList, 0, -1);
    $sql .= "(owner_id = {$_USER['uid']} AND perm_owner >= 2) OR ";
    $sql .= "(group_id IN ($groupList) AND perm_group >= 2) OR ";
    $sql .= "(perm_members >= 2) OR ";
}
$sql .= "(perm_anon >= 2))";

$order = " ORDER BY date DESC LIMIT $numstories";

$recs = DB_query($sql . $order);
$nrows = DB_numRows($recs);

$display .= '<ul>';

for ($x = 0; $x < $nrows; $x++) {
    $A = DB_fetchArray($recs);
    $display .= '<li>' . $A['date'] . "   ";
    $display .= '<a href="' . $_CONF['site_url'] . '/article.php/' . $A['sid'] . '">'
             . stripslashes($A['title']) . '</a>';
    $display .='</li>';   

}
                           
$display .= '</ul>';

return $display;

You can see it in action at the Iraq page. Enjoy TomW

 

What's Related

Story Options

Latest Stories in a Static Page | 0 comments | Create New Account
The following comments are owned by whomever posted them. This site is not responsible for what they say.
 Copyright © 2008 Plugins for Geeklog
 All trademarks and copyrights on this page are owned by their respective owners.
Powered By Geeklog 
Created this page in 0.17 seconds