root/branches/release-38/php/lib/function.mtauthordisplayname.php @ 2356

Revision 2356, 0.7 kB (checked in by takayama, 19 months ago)

Fixed BugId:79763
* When author object was not found in the context, try to load author object from entry in the context

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_mtauthordisplayname($args, &$ctx) {
9    // status: complete
10    // parameters: none
11    $author = $ctx->stash('author');
12    if (empty($author)) {
13        $entry = $ctx->stash('entry');
14        if (!empty($entry)) {
15            $author = $ctx->mt->db->fetch_author($entry['entry_author_id']);
16        }
17    }
18    if (empty($author)) {
19        return $ctx->error("No author available");
20    }
21    $author_name = $author['author_nickname'];
22    $author_name or $author_name =
23        $ctx->mt->translate('(Display Name not set)');
24    return $author_name;
25}
26?>
Note: See TracBrowser for help on using the browser.