Hi, I am trying to make one field programmable, but I am not doing something right.
This is my field (blueprints/fields/product-cover.php
).
<?php
$minwidth = page()->parent()->productImagewidth()->isNotEmpty() ? page()->parent()->productImagewidth() : '800';
$minheight = page()->parent()->productImageheight()->isNotEmpty() ? page()->parent()->productImageheight() : '800';
return [
'type' => 'image-clip',
'clip' => [
'minwidth' => $minwidth,
'minheight' => $minheight,
'ratio' => 'fixed'
],
'multiple' => 'false',
'layout' => 'cards',
'image' => [
'cover' => 'true'
],
];
The error I get is
Call to a member function productImagewidth() on null
I think it has something to do with parent()
part, it is not getting that. But it also doesn’t work with this
site()->children()->findBy('intendedTemplate', 'shop')
instead of page()->parent()
.
Any help is highly appreciated.