If attribute exisits do this...

Permalink 2 users found helpful
I'm looking for a piece of code that would display a div if the attribute is present if not then hide it.

Any help would be greatly appreciated.

 
jordanlev replied on at Permalink Best Answer Reply
jordanlev
Just get the attribute and then check if it's empty, like this:
<?php
$attr = $c->getAttribute('your_attribute_handle');
if (!empty($attr)): ?>
   <div>stuff in here</div>
<?php endif; ?>


(This is assuming you're talking about a page attribute in a theme template)
Creacionweb replied on at Permalink Reply
Creacionweb
Thanks, this helped me a lot.
MathiasB replied on at Permalink Reply
MathiasB
Thank You Jordan!
juddc replied on at Permalink Reply
juddc
Anyway to get this into a Page List template?

Edited - Nevermind - figured it out.

Super helpful.
JohntheFish replied on at Permalink Reply
JohntheFish
If you don't want to write PHP, doing that is easy with Magic Data.
juddc replied on at Permalink Reply
juddc
I've been meaning to have a look at it.