How to determine if Textarea Page Attribute is plain or rich text?

I’m grabbing a ‘textarea’ Page Attribute as such:

$atValObj = $c->getAttributeValueObject($this->attributeHandle);
$atTypeObj = $atValObj->getAttributeTypeObject();
$atTypeHandle = $atTypeObj->getAttributeTypeHandle();
if ($atTypeHandle == 'textarea') {
    ...
}

At this point I’d like to know if the ‘textarea’ Attribute is ‘Plain Text’ or ‘Rich Text’, as I’d like to modify ‘Plain Text’ only, leaving any ‘Rich Text’ Attributes as is. I’m not finding any obvious ways to accomplish this in the api. Anyone have experience with this, or can point me to the classes/methods I’m looking for? Be it a DB dig, happy to hear that as well :slight_smile:

Inside your if you should be able to do this

    $ak = $atValObj->getAttributeKey();
    $type = $ak->getAttributeKeySettings();
    if($type->getMode() === 'rich_text') {
        //do things here
    }

If it’s Plain Text the mode will be a blank string.

Spot on, Thank You!! I’ll try to remember to .zip or license you a copy of this package when it’s finished :slight_smile:

1 Like