Skip to main content Help Control Panel

YACS CMS : Open source !

Community «   Le forum «   To be integrated «  

recherche des categories se rapportant à un article

Cette fonction de shared/members.php est une base de travail. Je l'utilise pour afficher un pictogramme automatiquement à la place d'une vignette dans un layout d'article.

/**
* list alphabetically the categories related to a given anchor
*
* Actually list category by title. 
*
* Only category matching following criteria are returned:
*
* @param the target anchor
* @param int the offset from the start of the list; usually, 0 or 1
* @param int the number of items to display
* @param string the list variant, if any
* @return NULL on error, else an ordered array with $url => ($prefix, $label, $suffix, $icon)
*
* @see categories/print.php
* @see categories/view.php
*/
function &list_category_by_title_for_members($anchor$offset=0$count=10$variant=NULL) {
        global 
$context;

        
// locate where we are
        
if(!$variant)
            
$variant $anchor;

        
// limit the scope of the request
        
$where "";

        
// the list of articles
        
$query "SELECT categories.*"
            
." FROM (".SQL::table_name('members')." AS members"
            
.", ".SQL::table_name('categories')." AS categories)"
            
." WHERE (members.member LIKE '".SQL::escape($anchor)."')"
            
."    AND (CONCAT('category:',categories.id) = members.anchor)"
//            ."    AND ".$where
            
." ORDER BY categories.title LIMIT ".$offset.','.$count;
        
// use existing listing facility
        
$output =& Articles::list_selected(SQL::query($query), $variant);
        return 
$output;
    }

Comments

Bernard
avatar
from nearby-an-airport
Associate, 7053 posts

on Oct. 30 2008


Pourquoi ne pas utiliser la fonction Members::list_categories_by_title_for_member() qui existe déjà ?
Christian
avatar
from Chonas l'Amballan
Associate, 1063 posts

on Oct. 31 2008


Oui d'abord pourquoi hein ? On va mettre çà sur le compte de quoi ? mon état de fatigue avancé ? le fait de ne pas relever la tête du guidon et regarder autour ce qui se passe ?

Bref désolé pour ce dérangement !


Christian Loubechine
actupro

 
Christian Loubechine

avatar
Christian
on Oct. 30 2008
from Chonas l'Amballan

YACS team - responsable support
création site internet et annuaire pro Rhône-Alpes
Share
Information channels
Recent files