I'm trying to have a div show up only when a certain url is visited. I can't get a php function or javascript snippet to work, any help on how to do this would be greatly appreciated.
I added a custom function to ndxz-studio/site/plugin/index.php file by adding a custom function to my themes index.php page asthe code added to the plugin index page was:
function sidebarbuttons(){
if (substr($_SERVER['REQUEST_URI'], 0, 5) !== '/index.php?/books/why-unicorn-drinks/') {
echo 'html of div ';
}
}
I also tried using a javascript snippet where it would only show the div if it was a specific url, this is what I tried:
$(function(){
var url = document.location.href;
if (url.toLowerCase().indexOf('domain.com/…') >= 0) {
$('#mydiv').show();
} else {
$('#mydiv').show();
}
});
Neither of these seemed to work for me, I'm not sure what to do, any help or suggestions on this would be awesome.