NAME

Krang::Site - a means to access information on sites


SYNOPSIS

  use Krang::ClassLoader 'Site';
  # construct object
  my $site = Krang::Site->new(preview_url => 'preview.com',   # required
                              preview_path => 'preview/path/',# required
                              publish_path => 'publish/path/',# required
                              url => 'site.com');             # required
  # saves object to the DB and creates the root category '/' of the site
  $site->save();
  # getters
  my $id = $site->site_id();                    # undef until save()
  my $path = $site->preview_path();
  my $path = $site->publish_path();
  my $url = $site->preview_url();
  my $url = $site->url();
  # setters
  $site->preview_path( $new_preview_path );
  $site->publish_path( $new_publish_path );
  $site->url( $url );
  # delete the site from the database
  $site->delete();
  # a hash of search parameters
  my %params =
  ( order_desc => 1,            # result ascend unless this flag is set
    limit => 5,                   # return 5 or less site objects
    offset => 1,                  # start counting result from the
                                  # second row
    order_by => 'url'             # sort on the 'url' field
    preview_path_like => '%bob%', # match sites with preview_path
                                  # LIKE '%bob%'
    publish_path_like => '%fred%',
    preview_url => 'preview',     # match sites where preview_url is
                                  # 'preview'
    site_id => 8,
    url_like => '%.com%' );
  # any valid object field can be appended with '_like' to perform a
  # case-insensitive sub-string match on that field in the database
  # returns an array of site objects matching criteria in %params
  my @sites = pkg('Site')->find( %params );


DESCRIPTION

A site is the basic organizational unit within a Krang instance. A site may correspond to a web-site but only necessarily maps to a unique URL. Content within the site is stored within categories; see Krang::Category.

On preview, site output is written to paths under 'preview_path' and then the user is redirected to 'preview_url' - it is the same for 'publish_path' and 'url' upon publishing an asset.

This module serves as a means of adding, deleting, accessing site objects for a given Krang instance. Site objects, at present, do little other than act as a means to determine the urls and path associated with a site.

N.B - On save(), the root category for the site '/' is created.


INTERFACE

FIELDS

Access to fields for this object is provided my Krang::MethodMaker. The value of fields can be obtained and set in the following fashion:

 $value = $site->field_name();
 $site->field_name( $some_value );

The available fields for a site object are:

METHODS


TO DO


SEE ALSO

Krang, Krang::DB