webCOMAND

cObject::get_variant()

Returns the object that corresponds with the given set of dimensions, i.e. the 'French' version of a web page if passing the French dimension object.

An object will be returned only if one exists with exactly these specified dimensions.  If the object content type defines multiple dimension fields, but only one is provided in $dimension, then only the variant with just that dimension field set (and the others are not set) will be returned.

Prototype

Content get_dimension(cObject|array $dimensions)

Parameters

  • dimensions - Single dimension object, or array of dimension objects that correspond to the dimensions of the desired variant of this object.

Return

The variant representing the specified dimension(s) exactly, or NULL if not found.

Example

$repo = comand::repo();

// get Spanish Language Dimension Value
$es = $repo->get_first('FROM Language WHERE Title='Spanish');

// get the Spanish version of an Article
$article = $repo->get_first('FROM Article LIMIT 1');
$article_es = $article->get_dimension([$es]);
if($article_es) {
    echo("$article_es\n");
} else {
    echo("No Spanish version exists\n");
}