开发者

Else syntax Returning Error

      <?php if($this->item->params->get('itemExtraFields') && count($this->item->extra_fields)): ?>
      <!-- Item extra fields -->
      <div class="itemExtraFields">
          <h3><?php echo JText::_('Additional Info'); ?></h3>
          <ul>
            <?php foreach ($this->item->extra_fields as $key=>$extraField):?>


 <?php $user =& JFactory::getUser(); ?>
 <strong><?php if($extraField->name == "Price" && $user->get('guest') ==1) { ?></strong> 


<?php else: ?>   
                <li class="<?php echo ($key%2) ? "odd" : "even"; ?> type<?php echo ucfirst($extraField->type); ?> group<?php echo $extraField->group; ?>">
                    <span class="itemExtraFieldsLabel"><?php echo $extraField->name; ?>:</span>
                    <span class="itemExtraFieldsValue"><?php echo ($extraField->type=='date')?JHTML::_('date', $extraField->value, JText::_('K2_DATE_FORMAT_LC')):$extraField->value; ?></span>
                </li>
                <?php endif; ?>
            <?php endforeach; ?>
            </ul>
        <div class="clr"></div>
      </div>
      <?php endif; ?>

What seems to be the problem here? It's giving back an error of Parse e开发者_开发百科rror: syntax error, unexpected T_ELSE in.

This is for K2 Extrafield Visibility


You're mixing the if() : and if() { syntaxes. There's one if() { around the middle when everything else uses :.

Debugging tip: The error is very often in one line before the line that the error message points to.


You're mixing up different ways of using if-else statements. In the middle of that code, you open an if statement with a {, and then use else:. You also never close that if.


Change this -

<?php if($extraField->name == "Price" && $user->get('guest') ==1) { ?>

to this -

<?php if($extraField->name == "Price" && $user->get('guest') ==1): ?>
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜