I'm quite new to PHP. The problem statement is, I need to insert a CSS class into the nav on specific pages. Here's the way I have it now:
<nav class="navbar navbar-expand-md navbar-light fixed-top scrolling-navbar
<?php if (basename($_SERVER['PHP_SELF']) === 'index.php' || basename($_SERVER['PHP_SELF']) === 'shop.php' || basename($_SERVER['PHP_SELF']) === 'news.php') { echo "navbar-transparent"; } ?>
">
It works but it feels messy. I'm going to continue to research it (perhaps a switch statement is better?). Is there a cleaner way of doing this?
Cheers
Steve
Aucun commentaire:
Enregistrer un commentaire