March 11, 2004
yeah, ok MT (geekin, random re me)
So today I decided I'd like to have a list of the books I've read recently (besides the ones I'm reading RIGHT NOW) in my sidebar. It's there now, but only because I (and several other people) are awesome. Here's how it went:
MT: "You can't do that."(Conquistador == me + links below)
Conquistador: "0wn3d."
lastn entries by last modified on
I hate installing crap (DBI) when there is another way to do something, so I decided to try this:
which functionally fell short of what I wanted to do, in that it wouldn't let me filter out a certain number of posts from just one category. I grok perl, so I decided to MAKE IT WORK!!1 (code follows, beware)
The following code segment is what I had to change to display the last couple entries in my book category ordered descending by modified_on date:
in DateTags.pl around line 196: sub dt_n_entries { # skip some stuff my $cat_id = ''; if (defined $args->{category} ) { my $iter = MT::Category->load_iter({ blog_id => $ctx->stash('blog')->id }); my %cats; while (my $obj = $iter->()) { $cats{$obj->label()} = $obj->id(); } $cat_id = $cats{$args->{category}}; } my @entries = MT::Entry->load({ blog_id => $ctx->stash('blog')->id, status => MT::Entry::RELEASE() }, { sort => $column, start_val => $ts, direction => $direction, limit => $args->{'n'}, join => [ 'MT::Placement', 'entry_id', { category_id => $cat_id } ] }); # skip some more stuff } # end of functionI looked around at what I would have to change to add that functionality without also using a plugin, and got thoroughly confused. This way turned out to be easier, and doesn't introduce a performance hit when rebuilding the site as far as I can tell. Como esta el YAAAY!? Posted by yargevad at March 11, 2004 05:32 PM