Wiki Plume Community : CategoryById

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

Get Category Informations by ID

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


Obtenir des informations sur une catégorie à partir de son identifiant

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

/**
 Display the description of the current category.

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

function pxSingleCatDescriptionById($identifier, $s='%s', $limit=0)
{
    $c=$GLOBALS['_PX_render']['m']->getCategory($identifier);
    if (null !== $c) {
        if ($limit) {
            $text = substr(textParseContent($c->f('category_description'), 'text'), 0, $limit);
            echo sprintf($s, $text);
        } else {
            echo textParseContent($c->f('category_description'));
        }
    }
}

/**
 Display the category path

 @proto function pxSingleCatPath
 @param string identifier
 @param string s Substitution string ('%s')

 */

function pxSingleCatPathById($identifier, $s = '%s')
{
    global $_PX_website_config, $_PX_config;
    $c=$GLOBALS['_PX_render']['m']->getCategory($identifier);
    if (null !== $c) {
        $path = $_PX_website_config['rel_url'];
        if ($_PX_config['url_format'] == 'simple') {
            $path .= '/index.php?';
        }
        $path .= $c->f('category_path');
        echo sprintf($s, $path);
    }
}
?>
Valid XHTML 1.0 Transitional :: Valid CSS :: Powered by Wikka Wakka Wiki 1.1.6.1
Page was generated in 0.1100 seconds