Site logo

Archived topic

Displaying complex variables in an Element.

3 replies · Started by Andrew on October 25, 2020

Viewing posts 1–4 of 4

I'm using Meta Box to create custom fields for use in Elements - and they work great together - but a lot of the variables are more complex that a simple variable. In my case I'm wanting to retrieve a variable within an array - something like {{custom_field.array_name.variable_name}}

Also - As the field is conditional - I'd like to display the CTA conditionally. eg.

{% if custom_field.group_cta_fields %}
    {{custom_field.group_cta_fields.text_cta}}
{% endif %}

Is this possible?

or is it possible to somehow add a hook area conditionally within an Element?

Thanks.

Thanks. What about targeting variables in arrays?

foreach PHP iteration of variables should work within the shortcode.

You can even add conditions within it too.

Example:

...
foreach($array as $items ) { 
    $custom_field = $items->custom_field_name; 
    if(!$custom_field){
        //do something if $custom_field is empty.
    } else if ($custom_field){
        //do something if $custom_field has a value.
    }
}
...
This archived topic is closed to new replies.