NAME

Krang::Story - the Krang story class


SYNOPSIS

  # create a new story
  $story = pkg('Story')->new(title      => "Foo",
                             slug       => 'foo',
                             class      => 'article',
                             categories => [10, 20]);
  # basic setable fields
  $story->title("Life is very long");
  $story->slug("life");
  $story->cover_date(Time::Piece->strptime("1/1/2004 12:00", "%D %R"));
  # get the root element for this story
  my $element = $story->element();
  # add contributors
  $story->contribs(@contribs);
  # find some stories about Sam
  my @stories = pkg('Story')->find(title_like => '%sam%');
  # load a single story by id
  my ($story) = pkg('Story')->find(story_id => 1);
  # load a group of stories by id
  my ($story) = pkg('Story')->find(story_ids => [1, 20, 30, 100]);
  # save a story, incrementing version
  $story->save();
  # check it in, now other people can check it out
  $story->checkin();
  # checkout the story, no one else can edit it now
  $story->checkout();
  # revert to version 1
  $story->revert(1);
  # get list of stories linked to from this story
  my @linked_stories = $story->linked_stories;
  # get list of media linked to from this story
  my @linked_media = $story->linked_media;


DESCRIPTION

This class provides methods to operate on story objects. A story contains some story-specific data (title, cover date, etc.) and an element tree rooted in element, an object of the Krang::Element class.

Stories may be associated with contributors (objects of Krang::Contrib) and assigned scheduled actions (publish and expire).

Stories are checked-in, checked-out and versioned like media (Krang::Media) and templates (Krang::Template). However, unlike media and templates, they may also be moved to desks (Krang::Desk).

Stories may be assigned to multiple categories. However, one category is the primary category and determines the primary URL.


INTERFACE

Attributes

Story objects are composed of the following attributes. Unless otherwise noted all attributes are accessible via standard accessor/mutators. For example, the title attribute can be set with:

  $story->title("New title here");

And accessed with:

  $title = $story->title();

If an attribute is marked (readonly) then its value cannot be set. For example, you may not set checked_out directly; instead, call the checkout() method.

Methods