dilby
1
Hi all -
I need to change a conditional which checks if a field exists to if it contains a certain value …
Possibly a silly question but how do I make the below check if the ‘size’ field contains the word ‘small’?
<?php if($page->size()=isNotEmpty()): ?>
Thanks!
As a single word? As part of a string?
<?php if($page->size() == 'small'): ?>
<?php if(str::contains($page->size(), 'small' )): ?>
Something like this i think, off the top of my head. Not tested.
<?php
$field = $page->size()->value();
if (strpos($field, 'small') !== false) {
// do something if 'small' is in the string
}
?>
dilby
4
Thanks both, needed as a single word. Both options worked perfectly 