If field is equal to

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()): ?>


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.

$field = $page->size()->value();

if (strpos($field, 'small') !== false) {
    // do something if 'small' is in the string

Thanks both, needed as a single word. Both options worked perfectly :slight_smile: