Create a php menu that highlights current tab(创建一个突出显示当前选项卡的 php 菜单)
本文介绍了创建一个突出显示当前选项卡的 php 菜单的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
所以我在一个 php 文件中有一个菜单,看起来像这样(这是整个文件.我对 PHP 完全陌生.)
menu.php:
<li id="current"><a href="#"><span>首页</span></a></li><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):
<ul><!-- CSS 标签 --><?php include("menu.php");?>所以我想要做的是将上面的行更改为:
<?php include("menu.php?current=pictures");?>这将使活动选项卡成为图片选项卡.我该怎么做?
解决方案
你也可以试试这个:
你的php脚本
这是您的菜单:
<li <?php if ($selected == "pictures") 打印 $current_id;?>><a href="#"><span>首页</span></a></li><li <?php if ($selected == "blog") 打印 $current_id;?>><a href="http://blog.me.net/"><span>博客</span></a></li><li <?php if ($selected == "home") 打印 $current_id;?>><a href="http://www.me.net/R"><span>结果</span></a></li><li <?php if ($selected == "me") 打印 $current_id;?>><a href="http://www.me.net/P"><span>图片</span></a></li><li <?php if ($selected == "contacts") 打印 $current_id;?>><a href="http://www.me.net/O.html"><span>我们的位置</span></a></li>
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 菜单的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
织梦狗教程
本文标题为:创建一个突出显示当前选项卡的 php 菜单
基础教程推荐
猜你喜欢
- YouTube API v3 点赞视频,但计数器不增加 2022-01-01
- 如何在 Laravel 中使用 React Router? 2022-01-01
- Cron Jobs 调用带有变量的 PHP 脚本 2022-01-01
- 如何在 Laravel 5.3 注册中添加动态下拉列表列? 2021-01-01
- PHP PDO MySQL 查询 LIKE ->多个关键词 2021-01-01
- 如何替换eregi() 2022-01-01
- 学说 dbal querybuilder 作为准备好的语句 2022-01-01
- 有什么方法可以用编码 UTF-8 而不是 Unicode 返回 PHP`json_encode`? 2021-01-01
- 在PHP中根据W3C规范Unicode 2022-01-01
- PHP 类:全局变量作为类中的属性 2021-01-01
