开发者

Problems With PHPCode

I have an id field that is for example: field_obvious_advantage_value. And this field is inside a div. Now my problem is, when the field is disabled, div remains in its place, naturally with their classes. Anyone knows what the code should be written when the field is not active, div is also disabled?

I wrote the code开发者_如何学运维 that is the problem. When placed inside the page, white page and error message shows.

<?php if(!empty($node->field_obvious_advantage_value[0]['#value'])){?>
<?php print '<div>'; ?>
<?php print $node->field_obvious_advantage_value; ?>
<?php print '</div>'; ?>
<?php endif; ?>

Can you tell me, where is this code wrong?

Thanks a lot


I think you might have a problem with the 'if' statement, try:

<?php if(!empty($node->field_obvious_advantage_value[0]['#value'])): ?>
<?php print '<div>'; ?>
<?php print $node->field_obvious_advantage_value; ?>
<?php print '</div>'; ?>
<?php endif; ?>

Depending on your setup you maybe able to reduce this to:

<? if(!empty($node->field_obvious_advantage_value[0]['#value'])): ?>
<?= '<div>'.$node->field_obvious_advantage_value.'</div>' ?>
<? endif; ?>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜