I have a footer file with a contact us link and copyright information. When I click the contact us link, it will go to the contact us page. I have my footer as a php file and just include in the respective page. I would like to hide the contact us link when in the contact us page. How can I go about doing this?
footer.php
<?php
echo '<footer class="footer">
<div class="container">
<p class="text-muted"><a href="contactus.html">Contact Us</a></p>
<p class="text-muted"> Copyright © <span id="yearfooter"> </span>. All rights reserved.</p>
</div>
</footer>';
?>
You can do something like this. Instead of using echo
, just write the html outside the <?php ?>
tags and check the $_SERVER['REQUEST_URI']
and only show the link if it is not the contact page.
<footer class="footer">
<div class="container">
<?php if (strpos($_SERVER['REQUEST_URI'], '/contactus.html') !== 0) { ?>
<p class="text-muted"><a href="contactus.html">Contact Us</a></p>
<?php } ?>
<p class="text-muted"> Copyright © <span id="yearfooter"> </span>. All rights reserved.</p>
</div>
</footer>
This will work:
$page_name=preg_replace('#^(.+[\\\/])*([^\\\/]+)$#', '$2', $_SERVER['PHP_SELF']);
if ($page_name!="about-us.html") {
//display your link
}
you may try this ..
<footer class="footer">
<div class="container">
<p class="text-muted"><a id="a" href="contactus.html">Contact Us</a></p>
<p class="text-muted"> Copyright © <span id="yearfooter"> </span>. All rights reserved.</p>
</div>
</footer>
and in javascript
var pathname = window.location.pathname;
var appDomainEndding = 'yourdomain.com/app/'
if (pathname.toLowerCase().indexOf("contactus.html") > -1 ||
pathname.indexOf(appDomainEndding, pathname.length - appDomainEndding.length) > -1)
// add class to hide the a tag
{
document.getElementById("a").style.visibility = "hidden";
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.