创建一个突出显示当前选项卡的php菜单 [英] Create a php menu that highlights current tab
本文介绍了创建一个突出显示当前选项卡的php菜单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
所以我在一个php文件中有一个菜单,看起来像这样(这是整个文件,我完全是PHP的新手。)
menu.php :
< li id =current>< a href =#>< span> Home< ; /跨度>< / A>< /锂>
< li>< a href =http://blog.me.net/>< span>博客< / span>< / a>< / li>
< li>< a href =http://www.me.net/R>< span>结果< / span>< / a>< / li>
< li>< a href =http://www.me.net/P>< span>图片< / span>< / a>< / li>
< li>< a href =http://www.me.net/O.html>< span>我们的位置< / span>< / a>< / li>
现在在我的页面中,我这样做(index.php):
< div id =tabs1>
< ul>
<! - CSS标签 - >
<?php include(menu.php); ?>
< / ul>
< / div>
所以我想要做的是将上面的行更改为:
<?php include(menu.php?current = pictures); ?>
这将使活动选项卡成为图片选项卡。我怎么能这样做?
解决方案
您也可以试试这个:
您的 php
脚本
<?php
$ selected =pictures;
$ current_id ='id =current';
包含menu.php;
?>
这是您的菜单:
< UL>
< li<?php if($ selected ==pictures)print $ current_id; ?>>< a href =#>< span>主页< / span>< / a>< / li>
< li<?php if($ selected ==blog)print $ current_id; >>< a href =http://blog.me.net/>< span>博客< / span>< / a>< / li>
< li<?php if($ selected ==home)print $ current_id; ?>>< a href =http://www.me.net/R>< span>结果< / span>< / a>< / li>
< li<?php if($ selected ==me)print $ current_id; ?>>< a href =http://www.me.net/P>< span>图片< / span>< / a>< / li>
< li<?php if($ selected ==contacts)print $ current_id; ?>>< a href =http://www.me.net/O.html>< span>我们的位置< / span>< / a>< / li>
< / ul>
So I have a menu in a php file that looks like this (This is the whole file. I'm totally new to PHP.)
menu.php:
<li id="current"><a href="#"><span>Home</span></a></li>
<li><a href="http://blog.me.net/"><span>Blog</span></a></li>
<li><a href="http://www.me.net/R"><span>Results</span></a></li>
<li><a href="http://www.me.net/P"><span>Pictures</span></a></li>
<li><a href="http://www.me.net/O.html"><span>Our Location</span></a></li>
Now in my pages I do this (index.php):
<div id="tabs1" >
<ul>
<!-- CSS Tabs -->
<?php include("menu.php"); ?>
</ul>
</div>
So what I want to be able to do is change the line above to this:
<?php include("menu.php?current=pictures"); ?>
Which would make the active tab the Pictures tab. How can I do this?
解决方案
You could also try this:
Your php
script
<?php
$selected = "pictures";
$current_id = ' id="current"';
include "menu.php";
?>
this is your menu:
<ul>
<li <?php if ($selected == "pictures") print $current_id; ?>><a href="#"><span>Home</span></a></li>
<li <?php if ($selected == "blog") print $current_id; ?>><a href="http://blog.me.net/"><span>Blog</span></a></li>
<li <?php if ($selected == "home") print $current_id; ?>><a href="http://www.me.net/R"><span>Results</span></a></li>
<li <?php if ($selected == "me") print $current_id; ?>><a href="http://www.me.net/P"><span>Pictures</span></a></li>
<li <?php if ($selected == "contacts") print $current_id; ?>><a href="http://www.me.net/O.html"><span>Our Location</span></a></li>
</ul>
这篇关于创建一个突出显示当前选项卡的php菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文