Normally, my situation is easily solved using views rewrite feature.

However, in this case I am unable to use views rewrite because I have data attribute tags in the field wrappers that are stripped out by views. So I need to handle this at the template level. I have no problem getting the field data itself, but my issue is with the field wrappers. I need to use php if statements in either views-view-field.tpl.php or views-view-field.tpl.php to enclose the wrapper html too along with the field so it is not displayed for empty fields. But i can't figure out the php syntax to use to accomplish this. I need to be able to show the field data plus wrappers if the field has content, but show nothing (wrappers html included) if there is no data.

so far i have tried various approaches in views-view-field.tpl.php e.g,

<?php if (!empty($output)) : ?>
    <p class="tms-caption font-alt-1 text-medium weight-light color-white hide-on-mobile mb-30" data-animate-in="preset:slideInDownShort;duration:900ms;delay:500ms;" data-no-scale><?php print $output; ?></p>
<?php endif; ?>

unfortunately, i am not having any luck. any advice would be greatly appreciated. many thanks!

Comments

drupalstrap created an issue. See original summary.

mustanggb’s picture

That looks about right to me.

Are you sure your template file is being read, have you put the file in the right place, could you put some text outside of the if statement to see if it appears, have you cleared the views cache?

pyxio’s picture

@MustandGB, thanks for taking a look. Yes, I am sure the template is being read and in the correct place. If i hard code some debug text into the template file the text appears as it should. There is some problem with the php code i guess.

mustanggb’s picture

Did you solve this, I can't reproduce the issue, so I'm thinking it must be something specific to your setup.

renatog’s picture

Hi guys.

I tried and works good for me too.

I used two environments differents for it. My Local and Acquia.

@drupalstrap, if you can, please make your test using another environment, e.g. Acquia Cloud Free

This should work.

renatog’s picture

Status: Active » Fixed

Any question/extra detail please update for us.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.