开发者

Drupal 7, displaying page custom field with handling null exceptions

开发者 https://www.devze.com 2023-03-28 11:56 出处:网络
<?php if ($content[\'field_banner\']): ?> 开发者_如何学JAVA<div class=\"proj\"><?php print render($content[\'field_banner\']) ?></div>
 <?php if ($content['field_banner']): ?>
 开发者_如何学JAVA           <div class="proj"><?php print render($content['field_banner']) ?></div>
            <?php endif; ?>

My if condition is not working, if the page doesn't have banner, i am getting an error: Notice: Undefined index: field_banner in include() (line 28 of node.tpl.php


Maybe a little isset() can make the difference.

<?php if (isset($content['field_banner'])): ?>
0

精彩评论

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