Dotclear


Ignore:
Timestamp:
05/03/19 13:45:04 (6 years ago)
Author:
franck <carnet.franck.paul@…>
Branch:
default
Message:

Allow ?sub for category/categories attributes of tpl:EntryIf, and for url/urls attributes of fpl:CategoryIf, closes #2295

File:
1 edited

Legend:

Unmodified
Added
Removed
  • inc/core/class.dc.blog.php

    r3874 r3965  
    457457    { 
    458458        return $this->getCategories(['start' => $id, 'level' => $id == 0 ? 1 : 2]); 
     459    } 
     460 
     461    /** 
     462     * Returns true if a given category if in a given category's subtree 
     463     * 
     464     * @param      string   $cat_url    The cat url 
     465     * @param      string   $start_url  The top cat url 
     466     * 
     467     * @return     boolean  true if cat_url is in given start_url cat subtree 
     468     */ 
     469    public function IsInCatSubtree($cat_url, $start_url) 
     470    { 
     471        // Get cat_id from start_url 
     472        $cat = $this->getCategories(['cat_url' => $start_url]); 
     473        if ($cat->fetch()) { 
     474            // cat_id found, get cat tree list 
     475            $cats = $this->getCategories(['start' => $cat->cat_id]); 
     476            while ($cats->fetch()) { 
     477                // check if post category is one of the cat or sub-cats 
     478                if ($cats->cat_url === $cat_url) { 
     479                    return true; 
     480                } 
     481            } 
     482        } 
     483        return false; 
    459484    } 
    460485 
Note: See TracChangeset for help on using the changeset viewer.

Sites map