doumao1047 2012-04-26 13:03
浏览 54
已采纳

我的PHP条件语句显示if和else的两个结果,我的代码有什么问题?

I created a conditional statement for my custom theme in Concrete5. My codes goal is to toggle layout. If the current page has a child pages under it, it will display an additional sidebar (<div class="grid_3">) to list the subpages items. If there's no child page it would display a full layout (<div class="grid_13">).

Unfortunately I get a different result. there's something I probably had missed on my condition statement. Instead of just display one layout, It is rendering the two layout.

Below is what my code look like:

<? if($c->getNumChildren()) { ?>


<div class="grid_3">
    <?php   
    $bt_sidenav = BlockType::getByHandle('autonav');
    $bt_sidenav->controller->orderBy = 'display_asc';
    $bt_sidenav->controller->displayPages = 'below';
    $bt_sidenav->controller->displaySubPages = 'all';
    $bt_sidenav->render('view');
    ?>
</div>

<div id="main-content-container" class="grid_10">
    <div id="main-content-inner">
        <?php
        $a = new Area('Main');
        $a->display($c);
        ?>          
    </div>  
</div>

<? } else { ?>

<div id="main-content-container" class="grid_13">
    <div id="main-content-inner">
        <?php
        $a = new Area('Main');
        $a->display($c);
        ?>          
    </div>  
</div>

<? } ?>
  • 写回答

2条回答 默认 最新

  • dongnong3019 2012-04-26 13:05
    关注

    While your content generation portions of PHP use proper PHP tags (<?php … ?>), your if/else statements use short tags (<? … ?>) which are often disabled.

    Use <?php instead.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?
  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
  • ¥15 Arduino无法同时连接多个hx711模块,如何解决?