Geeklog France
 

New staticpages

Cette fonction est disponible dans la nouvelle version du plugin staticpages et permet d'afficher dans le block What's new (Quoi de neuf) la liste des dernières pages statiques créées.

On peut cloner cette fonction pour l'ajouter à un autre bloc, une autre page…

function phpblock_new_staticpages ()
{
    global $_CONF, $_TABLES, $_SP_CONF, $LANG_STATIC;

    $newstaticpagesinterval = 1209600;
    $includephp = 0;
    $includecenterblocks = 0;

    $retval = '';

    $extra_sql = "";
    if ($includecenterblocks == 0) {
        $extra_sql =' AND sp_centerblock = 0';
    }
    if ($includephp == 0) {
        $extra_sql .=' AND sp_php = 0';
    }

    $sql = "SELECT sp_id, sp_title
        FROM {$_TABLES['staticpage']}
        WHERE NOT ISNULL(sp_content) AND (sp_date >= (DATE_SUB(NOW(), INTERVAL {$newstaticpagesinterval} SECOND)))
        {$extra_sql}
        " . COM_getPermSQL( 'AND' ) . "
        ORDER BY sp_date DESC LIMIT 15";

    $result = DB_query( $sql );

    $nrows = DB_numRows( $result );

    if( $nrows > 0)
    {
        $newstaticpages = array();

        for( $x = 0; $x < $nrows; $x++ )
        {
            $A = DB_fetchArray( $result );

            $url = COM_buildUrl( $_CONF['site_url']
                . '/staticpages/index.php?page=' . $A['sp_id'] );

            $title = COM_undoSpecialChars( stripslashes( $A['sp_title'] ));
            $titletouse = COM_truncate( $title, $_SP_CONF['title_trim_length'],
                                        '...' );
            if( $title != $titletouse )
            {
                $attr = array('title' => htmlspecialchars($title));
            }
            else
            {
                $attr = array();
            }
            $astaticpage = str_replace( '$', '&#36;', $titletouse );
            $astaticpage = str_replace( ' ', '&nbsp;', $astaticpage );

            $newstaticpages[] = COM_createLink($astaticpage, $url, $attr);
        }

        $retval .= COM_makeList( $newstaticpages, 'list-new-comments' );
    }
    else
    {
        $retval .= $LANG_STATIC['no_new_pages'] . '<br' . XHTML . '>' . LB;
    }

    return $retval;
}
Connecté en tant que : Guest (Guest)
blocks/newstaticpages.txt · Dernière modification: 2009/11/11 15:32 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: 9