Created
April 25, 2009 01:30
-
-
Save phillipadsmith/101445 to your computer and use it in GitHub Desktop.
also_this_topic_march_27.mc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%args> | |
@secondary_categories | |
$skip_story_id => undef | |
$max_return => 5 | |
</%args> | |
<%perl> | |
# setting max_return to "0" (either by passing in value when calling, or adjusting above), means return everything. | |
my $count_returned=0; # default to returning everything found. | |
my $return_limit; #this is passed to the Bric::Biz... call -- requires special handling. | |
if(0==$max_return){ #unlimited | |
$return_limit = 0; | |
}else{ | |
$return_limit = $max_return + 1; #allow for potential match on a story ID we won't use | |
} | |
foreach my $secondary_cat (@secondary_categories){ | |
my $secondary_cat_id = $secondary_cat->{"id"}; | |
my @secondary_cat_stories = Bric::Biz::Asset::Business::Story->list({category_id=>$secondary_cat_id, publish_status=>1, Order=>"cover_date", OrderDirection=>"DESC", Limit=>$return_limit}); | |
foreach my $secondary_cat_story (@secondary_cat_stories){ | |
my $current_id = $secondary_cat_story->get_id; | |
if($skip_story_id != $current_id){ | |
++$count_returned; | |
my $secondary_cat_title = $secondary_cat_story->get_title; | |
my $secondary_cat_uri = $secondary_cat_story->get_uri; | |
my $secondary_cat_deck = $secondary_cat_story->get_data('deck'); | |
$m->print("<p><a href=\"$secondary_cat_uri\">$secondary_cat_title</a><br>$secondary_cat_deck</p>\n"); | |
if ($count_returned == $max_return) {last} | |
} | |
} | |
if ($count_returned == $max_return) {last} | |
} | |
</%perl> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment