Geeklog France

Last edited static pages block

/*
* phpblock_Staticpages: creates html listing all newly edited staticpages
*                       for inclusion in a block
*
* The function itself is very short and simple, but is set up so you can
* customise it easily.
*
* From Heather Engineering (http://www.heatherengineering.com/)
*/
 
function phpblock_Staticpages() {
    global $_CONF,$_TABLES;
 
// ------------------- CUSTOMISE THESE VARIABLES TO SUIT ------------------- //
 
    $lag = 60*60*24*7;             // seconds since edit to display as new
    $nothingnew = "No new pages";  // text to display when no pages to display
    $max_len = 15;                 // maximum length of string to display
    $max_pages = 10;               // maximum number of pages to show
 
                                   // start tag for date/new text
    $span_s = '<span style="float:right;color:red;font-size:x-small;">';
    $disp = "date";                // if "date" will show date, otherwise will
                                   // return contents of $disp (text/<img> tag
                                   // etc.)
    $span_e = '</span>';           // end tag for date/new text
 
                                   // format link to show in block
    if ($_CONF['url_rewrite'] == true) {
        $l = '<a href="'.$_CONF['site_url'].'/staticpages/index.php/%s"> %s </a>';
    } else {
        $l = '<a href="'.$_CONF['site_url'].'/staticpages/index.php?page=%s"> %s </a>';
    }
 
// ---------- YOU SHOULDN'T NEED TO CUSTOMISE ANYTHING BELOW HERE ---------- //
 
    $retval = '';
    $diff   = time()-$lag;
    $sql = "SELECT sp_id, sp_date, sp_title
            FROM {$_TABLES['staticpage']}
            ORDER BY sp_date DESC";
    $q = DB_Query($sql);
    $nrows = DB_numRows( $q );
    if( $nrows == 0 ) {
        $retval = $nothingnew;
    } else {
        for( $i = 0; $i < $max_pages; $i++ )
        {
            $A = DB_fetchArray( $q );
            if (strtotime($A['sp_date']) > $diff) {
                if (strlen($A['sp_title']) > $max_len) {
                    $A['sp_title'] = substr($A['sp_title'],0,$max_len).'...';
                }
                $retval .= sprintf($l, $A['sp_id'], $A['sp_title']);
                if ($disp=="date") {
                    $d = explode(" ",$A['sp_date']);
                } else {
                    $d = $disp;
                }
                $retval .= $span_s.$d[0].$span_e;
            $retval .= '<br>';
            }
        }
    }
    return $retval;
}
Connecté en tant que : Guest (Guest)
blocks/lasteditedstaticpages.txt · Dernière modification: 2009/01/17 17:16 par ::Ben
 

Download geeklog

Last version 1.8.1

Espace Membre





Devenir membre
Enregistrez-vous

Mot de passe oublié ?

Change language

Categories

  • Geeklog (38)
  • Plugins (53)
  • Thèmes (17)
  • My cart

    Votre panier (0 article)

    Votre panier est vide!

    0.00 EUR

    Visual Theme Switcher

    Test out available themes by selecting from one of the 6 available themes or give the Visual Switcher a try:

    Follow us on twitter

    En ligne

    Visiteurs: 10