root/branches/release-41/php/lib/function.mtentriescount.php @ 2655

Revision 2655, 0.9 kB (checked in by takayama, 17 months ago)

Fixed BugId:80318
* When entrieds in the stash is empty, re-fetch from database.

Line 
1<?php
2# Movable Type (r) Open Source (C) 2001-2008 Six Apart, Ltd.
3# This program is distributed under the terms of the
4# GNU General Public License, version 2.
5#
6# $Id$
7
8function smarty_function_mtentriescount($args, &$ctx) {
9    if ($ctx->stash('inside_mt_categories')) {
10        return $ctx->tag('MTCategoryCount', $args);
11    } elseif ($count = $ctx->stash('archive_count')) {
12        # $count is set
13    } else {
14        $entries = $ctx->stash('entries');
15        if (empty($entries) || !is_array($entries)){
16            $blog = $ctx->stash('blog');
17            $args['blog_id'] = $blog['blog_id'];
18            $entries =& $ctx->mt->db->fetch_entries($args);
19        }
20   
21        $lastn = $ctx->stash('_entries_lastn');
22        if ($lastn && $lastn <= count($entries))
23            $count = $lastn;
24        else
25            $count = count($entries);
26    }
27    return $ctx->count_format($count, $args);
28}
Note: See TracBrowser for help on using the browser.