How to show specific div only at specific url?

atfizzle / 2013-01-10 04:15:06   

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 as

the 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.

atfizzle / 2013-01-10 04:26:53   

Nevermind about this post, the javascript snippet I posted works. Resolved!

This thread has been closed, thank you.