Query pager via category slug.
14979
def query_pager_by_slug(slug, current_page_num=1, tag='', order=False):
        '''
        
        '''
        cat_rec = MCategory.get_by_slug(slug)
        if cat_rec:
            cat_id = cat_rec.uid
        else:
            return None

        # The flowing code is valid.
        if cat_id.endswith('00'):
            # The first level category, using the code bellow.
            cat_con = TabPost2Tag.par_id == cat_id
        else:
            cat_con = TabPost2Tag.tag_id == cat_id

        if tag:
            condition = {
                'def_tag_arr': [tag]
            }
            recs = TabPost.select().join(
                TabPost2Tag,
                on=((TabPost.uid == TabPost2Tag.post_id) & (TabPost.valid == 1))
            ).where(
                cat_con & TabPost.extinfo.contains(condition)
            ).order_by(
                TabPost.time_update.desc()
            ).paginate(current_page_num, CMS_CFG['list_num'])
        elif order:
            recs = TabPost.select().join(
                TabPost2Tag,
                on=((TabPost.uid == TabPost2Tag.post_id) & (TabPost.valid == 1))
            ).where(
                cat_con
            ).order_by(
                TabPost.order.asc()
            )
        else:
            recs = TabPost.select().join(
                TabPost2Tag,
                on=((TabPost.uid == TabPost2Tag.post_id) & (TabPost.valid == 1))
            ).where(
                cat_con
            ).order_by(
                TabPost.time_update.desc()
            ).paginate(current_page_num, CMS_CFG['list_num'])

        return recs
899999
def get_category_metrics(self, category):
        """"""
        slug_list = self._category_slugs(category)
        return self.get_metrics(slug_list)
816297
def prev(self, error_out=False):
        """"""
        return self.query.paginate(self.page - 1, self.per_page, error_out)
1299683
def view_or_add(self, slug):
        '''
        
        '''
        rec_page = MWiki.get_by_uid(slug)

        if rec_page:
            if rec_page.kind == self.kind:
                self.view(rec_page)
            else:
                return False
        else:
            self.to_add(slug)
1164779
private function selectByCategory($queryObject, $categoryID, $postTypeSlug)
    {
        $categoryRelationTable = categoriesRelationTable($postTypeSlug);
        return $queryObject->join($categoryRelationTable, $categoryRelationTable.'.postID', $postTypeSlug.'.postID')
            ->where($categoryRelationTable.'.categoryID', '=', $categoryID);
    }
1248056
public static function filterCategoriesByParentSlug($query, $slug) {
        $obj = \Delatbabel\NestedCategories\Models\Category::where('slug', $slug)->first();
        if ($obj) {
            $query->where('parent_id', $obj->id);
        } else {
            $query->where('slug', $slug);
        }
    }
318740
def get_category(cookie, tokens, category, page=1):
    '''
    '''
    timestamp = util.timestamp()
    url = ''.join([
        const.PAN_API_URL,
        'categorylist?channel=chunlei&clienttype=0&web=1',
        '&category=', str(category),
        '&pri=-1&num=100',
        '&t=', timestamp,
        '&page=', str(page),
        '&order=time&desc=1',
        '&_=', timestamp,
        '&bdstoken=', cookie.get('STOKEN').value,
    ])
    req = net.urlopen(url, headers={'Cookie': cookie.header_output()})
    if req:
        content = req.data
        return json.loads(content.decode())
    else:
        return None
907923
def recent(category=None, pages=1, sort=None, order=None):
	""""""
	s = Search()
	s.recent(category, pages, sort, order)
	return s
651437
function isBrowse(options) {
    var browse = true;

    if (options.id || options.slug) {
        browse = false;
    }

    return browse;
}
408603
def page_list(cls, pages, base_url='/'):
        """"""
        plist = []
        for page in pages:
            url = "<a href=\"{}{}\">{}</a>".format(base_url, cls.slugify(page), page)
            plist.append(url)
        return plist
90952
def get_by_slug(slug):
        '''
        
        '''
        rec = TabTag.select().where(TabTag.slug == slug)
        if rec.count() > 0:
            return rec.get()
        return None
1002339
def paginate(self, request, offset=0, limit=None):
        """"""
        return self.collection.offset(offset).limit(limit), self.collection.count()
1085528
def render_category(slug):
    """"""
    try:
        category = EntryCategory.objects.get(slug=slug)
    except EntryCategory.DoesNotExist:
        pass
    else:
        return {'category': category}
    return {}
230791
def get_type_by_url

      return 'P' if params[:slug].blank?

      # split the url up into segments
      segments = params[:slug].split('/')

      # general variables
      url = params[:slug]
      article_url = Setting.get('articles_slug')
      category_url = Setting.get('category_slug')
      tag_url = Setting.get('tag_slug')

      status = "(post_status = 'Published' AND post_date <= CURRENT_TIMESTAMP AND disabled = 'N')"

      # HACK: this needs to be optimised
      
      # is it a article post or a page post
      if segments[0] == article_url
        if !segments[1].blank?
          if segments[1] == category_url || segments[1] == tag_url
            # render a category or tag page
            return 'CT'
          elsif segments[1].match(/\A\+?\d+(?:\.\d+)?\Z/)
            # render the archive page
            return 'AR'
          else
            # otherwise render a single article page
            return 'A'
          end
        else
          # render the overall all the articles
          return 'C'
        end

      else
        # render a page
        return 'P'
      end

    end
217495
def get_category(self, slug):
        
        try:
            return get_category_for_slug(slug)
        except ObjectDoesNotExist as e:
            raise Http404(str(e))
909987
def get_one(slug):
    
    item = Product.objects.published()\
        .prefetch_related(Prefetch("paramvalue_set", queryset=ParamValue.objects.published().order_by('sort').prefetch_related("param")))\
        .filter(slug=slug).first()
    return item
303360
def get_by_slug(tag_slug):
        '''
        
        '''
        label_recs = TabTag.select().where(TabTag.slug == tag_slug)
        return label_recs.get() if label_recs else False