我是CakePHP的新手,我需要您的幫助。我需要在特定頁面上顯示特定的窗口小部件,這些窗口小部件是我的主頁,並禁用其餘頁面。基本上我已經能夠明確顯示基於日誌中的地位特殊的div如下所示:根據所選擇的頁面在CakePHP中禁用特定的div
<?php if (!$this->Session->read('Auth.User.id')): ?>
<div class="register link right <?php if ($active == 'register') echo 'active'; ?>"><?php echo $html->link('Register', array('controller' => 'users', 'action' => 'register')); ?></div>
<div class="login link right <?php if ($active == 'login') echo 'active'; ?>"><?php echo $html->link('Login', array('controller' => 'users', 'action' => 'login')); ?></div>
<?php else: ?>
<div class="logout link right"><?php echo $html->link('Logout', array('controller' => 'users', 'action' => 'logout')); ?></div>
<div class="myaccount link right <?php if ($active == 'myaccount') echo 'active'; ?>"><?php echo $html->link('My account', array('controller' => 'account', 'action' => 'summary')); ?></div>
<?php endif; ?>
我是問任何幫助,關於顯示基於我的主頁中選擇一個特定的div。
下面的僞代碼表示我的想法行我修來解決這個問題:
<?php if (the selected page is homepage or default.ctp)?>
// set the display property for the desired div to none
<?php else: ?>
// do not set the display property for the desired div to none
<?php endif; ?>
你的代碼有什麼問題? –
嗨,亞歷山德羅,謝謝你的回覆。爲什麼我無法確定在if語句括號內選擇了哪個視圖,我基本上失去了信心。我編輯了我的文章並添加了僞代碼來表示我的思路。另外我相信,一旦我確定頁面動態需要設置div的顯示樣式屬性,我打算禁用爲無。這在cakePHP中是如何動態實現的?謝謝 – TokTok123