
smith_t at denison
Jul 19, 2008, 6:42 AM
Post #8 of 8
(237 views)
Permalink
|
Worked great, thanks for the help. T On Fri, Jul 18, 2008 at 4:30 PM, David E. Wheeler <david[at]kineticode.com> wrote: > On Jul 18, 2008, at 11:27, Trevor Smith wrote: > >> I'm now trying to delete things as you mentioned by category using this >> code: >> >> my $cat = $story->get_primary_category->get_id; >> my @stories = Bric::Biz::Asset::Business::Story->list({ site_id >> => $story->get_site_id, category_id => $cat, active => 1, unexpired => >> 1, publish_status => 1, element_key_name => 'news_release' }); >> foreach my $story (@stories){ >> $story->delete_elements({ id => 1354 }); >> } >> >> But I am still getting this error: >> >> Can't locate object method "do_delete" via package >> "Bric::Biz::Element::Field" > > I've no idea what's happening there, but if what you want is to delete the > "mumble" fields associated with the top-level element of those stories, > you'd have to do this: > > foreach my $story (@stories) { > my $elem = $story->get_element; > if (my @fields = $elem->get_fields('mumble')) { > $elem->delete_elements(\@fields); > $elem->save; > } > } > > Note how I'm finding the fields to delete using key name rather than an ID. > > HTH, > > David >
|