public function tags($blogId, $includeCount = true, $onlyPopulated = true)
    {
        $oDb = Factory::service('Database');
        $oDb->select('t.id,t.blog_id,t.slug,t.label');

        if ($includeCount) {

            $sql  = '(SELECT COUNT(DISTINCT bpt.post_id) FROM ' . NAILS_DB_PREFIX . 'blog_post_tag bpt JOIN ';
            $sql .= NAILS_DB_PREFIX . 'blog_post bp ON bpt.post_id = bp.id WHERE bpt.tag_id = t.id AND ';
            $sql .= 'bp.is_published = 1 AND bp.is_deleted = 0 AND bp.published <= NOW()) post_count';

            $oDb->select($sql);
        }

        if ($onlyPopulated) {

            $oDb->having('post_count > ', 0);
        }

        $oDb->where('t.blog_id', $blogId);
        $oDb->order_by('t.label');

        $tags = $oDb->get(NAILS_DB_PREFIX . 'blog_tag t')->result();

        $this->load->model('blog/blog_tag_model');

        foreach ($tags as $tag) {

            $tag->url = $this->blog_tag_model->formatUrl($tag->slug, $tag->blog_id);
        }

        return $tags;
    }
public function tags($blogId, $includeCount = true, $onlyPopulated = true)
    {
        $oDb = Factory::service('Database');
        $oDb->select('t.id,t.blog_id,t.slug,t.label');

        if ($includeCount) {

            $sql  = '(SELECT COUNT(DISTINCT bpt.post_id) FROM ' . NAILS_DB_PREFIX . 'blog_post_tag bpt JOIN ';
            $sql .= NAILS_DB_PREFIX . 'blog_post bp ON bpt.post_id = bp.id WHERE bpt.tag_id = t.id AND ';
            $sql .= 'bp.is_published = 1 AND bp.is_deleted = 0 AND bp.published <= NOW()) post_count';

            $oDb->select($sql);
        }

        if ($onlyPopulated) {

            $oDb->having('post_count > ', 0);
        }

        $oDb->where('t.blog_id', $blogId);
        $oDb->order_by('t.label');

        $tags = $oDb->get(NAILS_DB_PREFIX . 'blog_tag t')->result();

        $this->load->model('blog/blog_tag_model');

        foreach ($tags as $tag) {

            $tag->url = $this->blog_tag_model->formatUrl($tag->slug, $tag->blog_id);
        }

        return $tags;
    }
public function tags ( $ blogId , $ includeCount = true , $ onlyPopulated = true ) { $ oDb = Factory :: service ( 'Database' ) ; $ oDb -> select ( 't.id,t.blog_id,t.slug,t.label' ) ; if ( $ includeCount ) { $ sql = '(SELECT COUNT(DISTINCT bpt.post_id) FROM ' . NAILS_DB_PREFIX . 'blog_post_tag bpt JOIN ' ; $ sql .= NAILS_DB_PREFIX . 'blog_post bp ON bpt.post_id = bp.id WHERE bpt.tag_id = t.id AND ' ; $ sql .= 'bp.is_published = 1 AND bp.is_deleted = 0 AND bp.published <= NOW()) post_count' ; $ oDb -> select ( $ sql ) ; } if ( $ onlyPopulated ) { $ oDb -> having ( 'post_count > ' , 0 ) ; } $ oDb -> where ( 't.blog_id' , $ blogId ) ; $ oDb -> order_by ( 't.label' ) ; $ tags = $ oDb -> get ( NAILS_DB_PREFIX . 'blog_tag t' ) -> result ( ) ; $ this -> load -> model ( 'blog/blog_tag_model' ) ; foreach ( $ tags as $ tag ) { $ tag -> url = $ this -> blog_tag_model -> formatUrl ( $ tag -> slug , $ tag -> blog_id ) ; } return $ tags ; }
Returns an array of a blog's tags
@param  integer $blogId        The ID of the blog to get tags from
@param  boolean $includeCount  Whether to include the post count of each tag
@param  boolean $onlyPopulated Whether to remove tags which don't have any posts in them
@return array
Returns an array of a blog s tags