La version française est disponible ici : CatMap
In order to add this function, you need to create:
- in manager/tools a folder named
myfunctions
- in manager/tools/myfunctions a file named
register.php
NB : the
register.php file must start with a:
<?php
and end with a:
?>
Add the following code inside
register.php:
/*
AFFICHAGE PLAN DETAILLE D'UNE CATEGORIE
DISPLAY THE "SITEMAP" OF A CATEGORY
*/
/*
titre et description de la sous-catégorie
title and description of the sub-category
*/
function pxTitleSubCat
($name,
$vals)
{
return sprintf('<h3><a href="%s" title="Liste complète des articles">%s</a></h3>'.
"\n".
'%s'.
"\n",
$vals['path'],
$name,
text::
parseContent($vals['desc']),
$name);
}
/*
contenu de la sous-catégorie
sub-category content
*/
function pxCatMapContent
($category,
$type,
$limit)
{
$list = pxSitemapCategoriesList
($category);
while (list
($name,
$vals) =
each ($list)) {
echo sprintf('%s'.
"\n", pxTitleSubCat
($name,
$vals));
echo '<ul>'.
"\n";
$cat =
$vals['id'];
$res = FrontEnd::
getResources($cat,
$limit,
$type);
$lang = config::
f('lang');
switch ($lang) {
case 'fr' :
$dateformat =
'%d/%m/%Y';
$next =
'Toutes les ressources publiées dans « '.
$name.
' »';
break;
// can be completed with other languages
default :
$dateformat =
'%m/%d/%Y';
$next =
'All resources in « '.
$name.
' »';
}
if ($res->
EOF()) {
} else {
while (!
$res->
EOF()) {
echo sprintf('<li>'.strftime
($dateformat,
date::
unix($res->
f('publicationdate'))).
' : <a href="%s">%s</a></li>'.
"\n",
$res->
getPath(), px_removeNumbers
($res->
f('title')));
$res->
moveNext();
}
echo '</ul>'.
"\n\n";
echo ('<p class="nb_ressources"><a href="'.
$vals['path'].
'">'.
$next.
'</a></p>'.
"\n\n");
}
}
}
/*
fonction utilisée dans la page pour composer le plan de la catégorie
function to be used in the template du display the "CATMAP"
*/
function pxShowCatMap
($type=
'all',
$limit=
'10')
{
if ($type ==
'all') {
$type =
'';
}
$rootcat =
$GLOBALS['_PX_render']['cat']->
f('category_id');
pxCatMapContent
($rootcat,
$type,
$limit,
0);
}
The function can then be used in the template
resource_article.php with:
<?php pxShowCatMap('all', 5); ?>
Exactly like for the sitemap, the function comes with two parameters:
-
$limit : integer for the number of resources to display (default = 10);
-
$type :
' ' or 'all' : display all kind of resources (news and articles) ;
'news' : display the news ;
'articles' : display the articles.
Page was generated in 1.1138 seconds