Closed Aharito closed 6 years ago
Hm, maybe it can be solved by prepare function Example (not tested):
'prepare' => function($options, $values) {
foreach ($values['images'] as &$image) {
$image['crop'] = $values['crop_global'];
}
unset($image);
}
Based on the code of your pagebuilder.php file, should the "prepare" function be inserted into an options array of the corresponding field? and what field is corresponding? "images"?
Following example not work:
'images' => [
'caption' => 'Картинки',
'type' => 'group',
'prepare' => function($options, $values) {
foreach ($values['images'] as &$image) {
$image['crop'] = $values['crop_global'];
}
unset($image);
},
'fields' => [
'image' => [
'caption' => 'Картинка',
'type' => 'image',
],
],
'templates' => [
'owner' => '[+images+]',
//crop_global must be "global" crop values for all images and be set once
'images' => '<img src="[[phpthumb? &input=`[+image+]` &options=`[+crop_global+]`]]">',
],
'fields' => [
//crop_global
'crop_global' => [
'caption' => 'Обрезка картинок',
'type' => 'dropdown',
'elements' => 'w=1074||w=537||w=268',
],
'images' => [
'caption' => 'Картинки',
'type' => 'group',
'fields' => [
'image' => [
'caption' => 'Картинка',
'type' => 'image',
],
],
],
],
'prepare' => function($options, $values) {
foreach ($values['images'] as &$image) {
$image['crop'] = $values['crop_global'];
}
unset($image);
}
Unfortunately, not work.
I tried using [+crop+]
instead of [+crop_global+]
in 'images'
template, but it still does not work.
Try
'prepare' => function($options, &$values) {
instead of
'prepare' => function($options, $values) {
Thanks, 'prepare' => function($options, &$values)
variant works well with [+crop+]
placeholder.
How to use a "global placeholder" (field) from a "wrapping" field in nested group field? Example:
I would like to set the crop_global field once, not to set it separately for each image. So that the crop_global value would be used to crop any new image in the nested "images" group field.
But inside the nested template, the "external" placeholder is not available. Are there any solutions?