Wiki Plume Community : ArticleById

HomePage :: Categories :: PageIndex :: RecentChanges :: RecentlyCommented :: Login/Register

Get Article Informations by ID

Sometimes it is usefull to access article informations by its ID.
You can add those functions in functions.php :


Obtenir des informations sur un article à partir de son identifiant

Il est parfois utile d'obtenir des informations sur un article donné à partir de son identifiant.
Voici deux fonctions permettant de le faire, à ajouter dans functions.php :



/**
 Display the description of the article.

 @proto function pxArtDescriptionById
 @param string identifier
 @param string s Substitution string ('%s')
 @param int limit maximum length of the output text (0)
*/

function pxArtDescriptionById($identifier, $s='%s', $limit=0)
{
    $a=$GLOBALS['_PX_render']['m']->getArticle($identifier, 1);
    if (null !== $a) {
        if ($limit) {
            $text = substr(textParseContent($a->f('description'), 'text'), 0, $limit);
            echo sprintf($s, $text);
        } else {
            echo textParseContent($a->f('description'));
        }
    }
}

/**
 Display the path to the article.

 @proto function pxArtPath
 @param string type 'full' give path with http:// ('relative')
*/

function pxArtPathById($identifier, $type = 'relative')
{
    global $_PX_website_config, $_PX_config;
    $a=$GLOBALS['_PX_render']['m']->getArticle($identifier, 1);
    if (null !== $a) {
        $s = ($_PX_website_config['secure']) ? 's' : '';
        switch ($type) {
            case 'full' : $path = 'http'.$s.'://'.$_PX_website_config['domain'].$_PX_website_config['rel_url']; break;
            default : $path = $_PX_website_config['rel_url']; break;
        }
        if ($_PX_config['url_format'] == 'simple') {
            $path .= '/index.php?';
        }
        $path .= $a->getPath();
        echo $path;
    }

}
Valid XHTML 1.0 Transitional :: Valid CSS :: Powered by Wikka Wakka Wiki 1.1.6.1
Page was generated in 0.7105 seconds