M
M
mygfechicks2020-05-19 14:16:52
Drupal
mygfechicks, 2020-05-19 14:16:52

Adding layer in php how?

In the Drupal template, I'm trying to display the layer on the photo, depending on the filling of the field inside the admin panel. I write in the format:

<?php if(!empty($fields['field_video'])) echo '<div class="ribbon-wrapper-gold"><div class="ribbon-gold">with video</div></div>'; ?>

The ibbon-wrapper-gold layer always appears this way, whether the field_video field is filled or not. How to fix it?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
Nikita Remizov, 2020-11-08
@niremizov

Most likely the value of $fields['field_video'] is never empty, so the layer is always rendered.
1) Dump the contents of the value to the screen var_dump($fields['field_video']);
2) Look at the value structure, it is probably an array that contains the value key - which already stores the value that you need to check.
As a result, the check will most likely turn out like this: !empty($fields['field_video']['value']

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question