webCOMAND

Content::add_dimension()

Creates a new dimension as a copy of the current object. This will not guarantee that the object dimension is unique; i.e. two users can simultaneously add two 'French' web pages (this can be resolved by the users later and will not break the query engine). Returns the new dimension working copy (that has not yet been stored).

Prototype

Object add_dimension(mixed $dimension_data, Content $copy = NULL)

Parameters

  • dimension_data - A dimension (object of a type that extends Dimension), or an array or collection of dimensions that will be set in the returned object.
  • copy - Optional object to update as the new dimension variant, rather than creating a new one (default).

Return

The new Content variant is returned, which will be the same as $copy Content if specified.  If the new variant could not be created, FALSE is returned.

Example

$repo = comand::repo();

// get languages
$en = $repo->get_first('FROM Language WHERE Title='English');
$es = $repo->get_first('FROM Language WHERE Title='Spanish');

// create a new Article in English
$article_en = $repo->new_object('Article');
$article_en->Title = 'Dimensions';
$article_en->Language = $en;
$article_en->approve();

// translate the English Article to Spanish
$article_es = $article_en->add_dimension([$es]);
$contact->Title = 'Dimensiones';
$contact->approve();