Indexhibit
Index + Exhibit

Login:

Created by
Daniel Eatock
Jeffery Vaska
And You

How to show specific div only at specific url?

 

Indexhibit version: Legacy
Thread is resolved.

atfizzle
UNITED STATES
2 year(s) ago
Permalink Post

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
UNITED STATES
2 year(s) ago
Permalink Post

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

 

This thread has been closed, thank you.