Changeset 2933

Show
Ignore:
Timestamp:
08/18/08 08:04:24 (4 months ago)
Author:
auno
Message:

Implemented MTAuthorEntryCount tags. BugzID:54117

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lib/MT/Template/ContextHandlers.pm

    r2923 r2933  
    298298            AuthorUserpicURL => \&_hdlr_author_userpic_url, 
    299299            AuthorBasename => \&_hdlr_author_basename, 
     300            AuthorEntryCount => \&_hdlr_author_entry_count, 
    300301 
    301302            BlogID => \&_hdlr_blog_id, 
     
    68226823########################################################################### 
    68236824 
     6825=head2 AuthorEntryCount 
     6826 
     6827Returns the number of published entries associated with the author 
     6828currently in context. 
     6829 
     6830=for tags authors 
     6831 
     6832=cut 
     6833 
     6834sub _hdlr_author_entry_count { 
     6835    my ($ctx, $args, $cond) = @_; 
     6836    my $author = $ctx->stash('author'); 
     6837    unless ($author) { 
     6838        my $e = $ctx->stash('entry'); 
     6839        $author = $e->author if $e; 
     6840    } 
     6841    return $ctx->_no_author_error() unless $author; 
     6842 
     6843    my (%terms, %args); 
     6844    my $class = MT->model('entry'); 
     6845    $ctx->set_blog_load_context($args, \%terms, \%args) 
     6846        or return $ctx->error($ctx->errstr); 
     6847    $terms{author_id} = $author->id; 
     6848    $terms{status}    = MT::Entry::RELEASE(); 
     6849    my $count = $class->count(\%terms, \%args); 
     6850    return $ctx->count_format($count, $args); 
     6851} 
     6852 
     6853########################################################################### 
     6854 
    68246855=head2 Blogs 
    68256856