我希望我的导航栏图标在用户位于某个页面时(例如在 instagram 等)上改变颜色。这就是我尝试过的 - bottomBar.php:
if ($page == 'friends') {
$theme = 'link_friendsWall_active';
$theme2 = 'link_index';
$theme3 = 'link_trophypage';
$theme4 = 'link_selfpage';
} else if ($page == 'index') {
$theme = 'link_friendsWall';
$theme2 = 'link_index_active';
$theme3 = 'link_trophypage';
$theme4 = 'link_selfpage';
} else if ($page == 'trophy') {
$theme = 'link_friendsWall';
$theme2 = 'link_index';
$theme3 = 'link_trophypage_active';
$theme4 = 'link_selfpage';
} else if ($page == 'profile') {
$theme = 'link_friendsWall';
$theme2 = 'link_index';
$theme3 = 'link_trophypage';
$theme4 = 'link_selfpage_active';
}
$page 是指在 index.php(作为索引)、friendsWall.php(作为朋友)等文件中定义的变量,其中包含 bottom_menu。主题定义的变量是在 css 中设置样式的类。然后在我的底部菜单中,我调用了这些变量:
<div class="bottom_menu">
<li><a class="<?=$theme?>" href="includes/handlers/friends_link.php">
<i class="fas fa-user-friends"></i>
</a></li>
<li><a class="<?=$theme2?>" href="index.php">
<i class="fas fa-users "></i>
</a></li>
<li><a href="#">
<i class="fas fa-plus-circle"></i>
</a></li>
<li><a class="<?=$theme3?>" href="trophyPage.php">
<i class="fas fa-trophy"></i>
</a></li>
<li><a class="<?=$theme4?>" href="myProfile.php">
<img class='img_bottom_bar' src="<?php echo $user['profile_pic']; ?>" width="30px" height="30px" border-radius="20px">
</a></li>
</div>
我的问题是该网站没有从其他页面读取变量 $page 。索引.php:
session_start();
include("includes/header.php");
include("includes/bottomBar.php");
include("includes/classes/User.php");
include("includes/classes/Post.php");
$page = 'index';
慕标5832272
米琪卡哇伊
千巷猫影