By Boogle on
Hi everyone,
Basically I want to hide the cck field label when no data has been entered.
Here is my current code for displaying a mobile phone number. It works ok but if no number is entered it still displays the field label.
<?php foreach ((array)$field_mobile as $item) { ?>
<?php print $node->content['group_contact_details']['group']['field_mobile']['field']['#title'] ?>
<?php } ?></p>
Any suggestions?
Comments
Sorry, this.
Missed a bit.
Thanks
Sounds like you
Sounds like you want
Yep, that’s it!
Thank you very much, works perfectly.
Label class and display above?
Ok, this is working nicely but I want a bit more control over the label. What do I need to do to display the label above and also put a class on it so I can add some CSS.
Thanks
Not sure what you mean by
Not sure what you mean by "display the label above" but if you mean only once for the set of values how about
That’s perfect
I meant I want the field label to be above the content rather than inline, for example:
Mobile:
08777 888 888
The code you’ve written does that, thank you very much.
I have a similar issue. I've
I have a similar issue. I've a custom content type and used contemplate to create a custom node tpl file but want to hide non-required fields that are empty. The problem I guess is that I have some CSS that handles headings for these non-required fields so when the field is empty, the Headings still appear.
The node tpl file has -
class="specials-heading" Honeymoon Packages and class="specials" that provides a border and other text styling for the following php snippet
print $node->field_honeymoon_package[0] ['view']Is it possible to hide the "Honeymoon Packages" heading and the border when no text is entered into the field?
ok, thanks to the code
ok, thanks to the code suggested above, this worked for me :
You can simplify this
You can simplify this to
or if there really can be more than one value you would want to change $node->field_honeymoon_package[0]['view'] in the print statement to $honeymoon_package.