root/branches/release-35/php/lib/block.mtentrycategories.php @ 1926

Revision 1926, 1.4 kB (checked in by takayama, 20 months ago)

Fixed BugId:76389
* Loop tags does not add 'glue', if row in loop tag was empty

  • MTFor
  • MTLoop
  • MTTags
  • MTEntryTags
  • MTEntries
  • MTEntryCategories
  • MTCategories
  • MTEntryAdditionalCategories
  • MTParentCategories
  • MTAssetTags
  • MTPagerBlock
  • Property svn:keywords set to Author Date Id Revision
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_block_mtentrycategories($args, $content, &$ctx, &$repeat) {
9  $localvars = array('_categories', 'category', '_categories_counter', '__out');
10    if (!isset($content)) {
11        $ctx->localize($localvars);
12        $entry = $ctx->stash('entry');
13        $args['entry_id'] = $entry['entry_id'];
14        $categories = $ctx->mt->db->fetch_categories($args);
15        $ctx->stash('_categories', $categories);
16        $ctx->stash('__out', false);
17        $counter = 0;
18    } else {
19        $categories = $ctx->stash('_categories');
20        $counter = $ctx->stash('_categories_counter');
21        $out = $ctx->stash('__out');
22    }
23    if ($counter < count($categories)) {
24        $category = $categories[$counter];
25        $ctx->stash('category', $category);
26        $ctx->stash('_categories_counter', $counter + 1);
27        $repeat = true;
28        if (isset($args['glue']) && !empty($content)) {
29            if ($out)
30                $content = $args['glue'] . $content;
31            else
32                $ctx->stash('__out', true);
33        }
34    } else {
35        if (isset($args['glue']) && $out && !empty($content))
36            $content = $args['glue'] . $content;
37        $ctx->restore($localvars);
38        $repeat = false;
39    }
40    return $content;
41}
42?>
Note: See TracBrowser for help on using the browser.