0
如何在兩個不同的佈局文件中包含相同的導航欄?我不想在2個佈局文件中重複導航條碼。cakephp:如何在兩個不同的佈局文件中包含相同的導航欄
下面是我的導航欄代碼:
<?php
echo $this->Html->css('nav_bar.css');
?>
<script language="javascript" type="text/javascript">
sfHover = function() {
var sfEls = document.getElementById("navbar").getElementsByTagName("li");
for (var i=0; i<sfEls.length; i++) {
sfEls[i].onmouseover=function() {
this.className+=" hover";
}
sfEls[i].onmouseout=function() {
this.className=this.className.replace(new RegExp(" hover\\b"), "");
}
}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);
</script>
<div id="menu">
<ul id="nav">
<li><?php echo $this->Html->link('Home', '/pages/home', array()); ?></li>
<li><?php echo $this->Html->link('Our Program', '#', array()); ?><ul>
<li><?php echo $this->Html->link('Preschool', '/pages/preschool',
array()); ?></li>
<li><?php echo $this->Html->link('Kindergarten', '/pages/kindergarten', array()); ?></li>
<li><?php echo $this->Html->link('Summer Camp', '/pages/summer_camp', array()); ?></li>
</ul>
</li>
<li><?php echo $this->Html->link('About Us','#', array()); ?><ul>
<li><?php echo $this->Html->link('Merry Flowers', '/pages/about_us', array()); ?></li>
<li><?php echo $this->Html->link('Tour Our School','/pages/tour_our_school', array()); ?></li>
<li><?php echo $this->Html->link('Contact Us', '/pages/contact_us', array()); ?></li>
</ul>
</li>
<li><?php echo $this->Html->link('Events','#', array()); ?><ul>
<li><?php echo $this->Html->link('News & Events', '#', array()); ?>
<ul>
<li><?php echo $this->Html->link('Sports Day','/pages/sports_day',array()); ?></li>
</ul>
</li>
<li><?php echo $this->Html->link('List of Holidays', '/pages/list_of_holidays', array()); ?></li>
</ul>
</li>
<li><a href="#">FAQ</a><ul>
<li><?php echo $this->Html->link('FAQ', '/pages/faq', array()); ?></li>
<li><?php echo $this->Html->link('Feedback', '/feedbacks/add', array()); ?></li>
<li><?php echo $this->Html->link('Discussion', '/pages/discussion', array()); ?></li>
</ul>
</li>
<li><a href="#">Admissions</a><ul>
<li><?php echo $this->Html->link('Enroll Now','/students/add', array()); ?></li>
</ul>
</li>
</ul><!--finish ul nav-->
</div> <!--finish div menu-->
謝謝。
是的,$ this-> element('navbar')工作得很好。儘管如此,我仍然需要閱讀第二個參數。非常感謝。 :) – vaanipala