Created
September 14, 2009 14:31
-
-
Save sinkovsky/186681 to your computer and use it in GitHub Desktop.
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
if ( $params{categories} ) { | |
for my $category ( @{$params{categories}}) { | |
my $cat = MT::Category->load({label => $category, | |
blog_id => $entry_new->blog_id}); | |
unless ($cat) { | |
print "Category $category not found. Creating...\n" if $self->{'verbose'}; | |
$cat = MT::Category->new; | |
$cat->blog_id($entry_new->blog_id); | |
$cat->label($category); | |
$cat->save or die $cat->errstr; | |
} | |
my $placement = MT::Placement->new; | |
$placement->entry_id($entry_new->id ); | |
$placement->blog_id($entry_new->blog_id ); | |
$placement->category_id( $cat->id ); | |
$placement->is_primary(0); | |
$placement->save or die $placement->errstr; | |
print "Placing entry under category $category\n" if $self->{'verbose'}; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment