Help - Search - Members - Calendar
Full Version: MTTopLevelCategories does create proper context
Movable Type Community Forum > Other Product Discussion > Bugs and Odd Behavior
markcarey
Using an MTEntries container within MTTopLevelCategories does not display only entries within that category -- instead it seems to assume a global context.

I am doing this in an index template:

CODE
<MTTopLevelCategories>

<MTEntries>

</MTEntries>

</MTTopLevelCategories>
markcarey
This problem seems to also exist within MTSubCategories
markcarey
I really needed this to work, so I edited the source. It seems to have worked, but I am an amateur at such things, so perhaps I broke something else in the process.

In mt/lib/MT/Template/Context.pm, after the line:

CODE
   local $ctx->{__stash}->{'subCatIsLast'} = !scalar (@$cats);

(around line 2603)

I pasted the following (from the SubCategories hdlr):

CODE
###cut and pasted from MTCategories
   use MT::Promise qw(delay force);
   my $blog_id = $ctx->stash('blog_id');
   my $needs_entries = ($ctx->stash('uncompiled') =~ /<\$?MTEntries/) ? 1 : 0;
       local $ctx->{__stash}{entries};
       local $ctx->{__stash}{category_count};
       my @args = (
           { blog_id => $blog_id,
             status => MT::Entry::RELEASE() },
           { 'join' => [ 'MT::Placement', 'entry_id',
                         { category_id => $cat->id } ],
             'sort' => 'created_on',
             direction => 'descend', });
       if ($needs_entries) {
           my @entries = MT::Entry->load(@args);
           $ctx->{__stash}{entries} = delay(sub{\@entries});
           $ctx->{__stash}{category_count} = scalar @entries;
       } else {
           $ctx->{__stash}{category_count} = MT::Entry->count(@args);
       }
###end of cut and paste from MT Categories
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Invision Power Board © 2001-2008 Invision Power Services, Inc.