Dotclear

Ticket #389 (closed defect: fixed)

Opened 17 years ago

Last modified 17 years ago

cat_id and cat_url filter in array for dcBlog::getCategories.

Reported by: adjaya Owned by: olivier
Priority: normal Milestone: 2.1
Component: module:core Version: 2.0
Severity: normal Keywords:
Cc:

Description

Tout est dans le titre, c'est dommage que les possibilités de filtrages soit si pauvre sur la liste des catégories, ca serait bien pratique !

Change History

comment:1 follow-up: ↓ 3 Changed 17 years ago by olivier

  • Status changed from new to closed
  • Resolution set to invalid

Si on parle bien la méthode getCategories de la classe dcBlog, ces filtres existent.

comment:2 Changed 17 years ago by philippe

euh... si on pouvait passer en argument le blog_id, ça serait quand même pratique pour un multiblog. Actuellement on ne peut récupérer que les infos des catégories du blog courant, ça pourrait être le réglage par défaut.

comment:3 in reply to: ↑ 1 Changed 17 years ago by adjaya

  • Status changed from closed to reopened
  • Resolution invalid deleted

Replying to olivier:

Si on parle bien la méthode getCategories de la classe dcBlog, ces filtres existent.

Oui, mais pas pour un filtrage sur plusieurs catégories à la fois : actuellement on a ca sur la dernière révision de class.dc;blog.php (révision 2181, ligne 251 ):

251                if (!empty($params['cat_url'])) {
252 	                        $strReq .= "AND cat_url = '".$this->con->escape($params['cat_url'])."' ";
253 	                }
254 	               
255 	                if (!empty($params['cat_id'])) {
256 	                        $strReq .= 'AND C.cat_id = '.(integer) $params['cat_id'].' ';
257 	                }

et moi je pensais à ca :

		if (!empty($params['cat_url']))
		{
			if (is_array($params['cat_url'])) {
				array_walk($params['cat_url'],create_function('&$v,$k','$v=(string)$v;'));
			} else {
				$params['cat_url'] = array((string) $params['cat_url']);
			}
			
			if (empty($params['cat_url_not'])) {
				$strReq .= 'AND C.cat_url '.$this->con->in($params['cat_url']);
			} else {
				$strReq .= 'AND (C.cat_url IS NULL OR C.cat_url NOT '.$this->con->in($params['cat_url']).') ';
			}
		}
		
		if (!empty($params['cat_id']))
		{
			if (is_array($params['cat_id'])) {
				array_walk($params['cat_id'],create_function('&$v,$k','if($v!==null){$v=(integer)$v;}'));
			} else {
				$params['cat_id'] = array((integer) $params['cat_id']);
			}
			
			if (empty($params['cat_id_not'])) {
				$strReq .= 'AND P.cat_id '.$this->con->in($params['cat_id']);
			} else {
				$strReq .= 'AND (P.cat_id IS NULL OR P.cat_id NOT '.$this->con->in($params['cat_id']).') ';
			}
		}

Comme pour dcBlog::getPosts ou ce type de filtrage est possible.

comment:4 Changed 17 years ago by olivier

  • Status changed from reopened to closed
  • Resolution set to fixed

Résolu avec l'arrivée des catégories multiples.

Note: See TracTickets for help on using tickets.

Sites map