- ⌂ cObject
- Methods
- Constructor
- add_variant()
- approve()
- as_array()
- can_add_variant()
- can_delete_variant()
- can_edit_variant()
- can_reorder_variant()
- clone()
- delete()
- edit_variant()
- enum()
- get_active_object()
- get_all_variants()
- get_attributes()
- get_dimensions()
- get_dimension_with()
- get_parent()
- get_primary_cpath()
- get_variant()
- Keywords()
- lock_object()
- reload_data()
- repo()
- revert()
- save()
- store()
- unlock_object()
- update_from_array()
- validate()
cObject::edit_variant()
Creates a new variant for the content object this model represents. The new variant's initial values will be based on the values of this model, with the exception of the dimensions passed here as an option.
This function will not check authorizations for editing variants, nor will it ensure that the variant is unique within this content object; both are verified during validation.
Prototype
void edit_variant(cObject|array $dimensions = NULL)
Parameters
- dimensions - The dimension or array of dimensions to apply to the variant. If none are specified, the variant dimensions will not be modified.
Example
$repo = comand::repo();
// get French and Spanish Language Dimensions
$fr = $repo->get_first("FROM Language WHERE Title='French'");
$es = $repo->get_first("FROM Language WHERE Title='Spanish'");
// get the French variant of an Article
$article = $repo->get_first("FROM Article WHERE Title='Article Title'");
$article_fr = $article->get_variant($fr);
if($article_fr) {
// change the French variant to a Spanish variant
$article_fr->edit_variant($es);
$article_fr->Title = 'Título del artículo';
$article_fr->approve();
}