I have a pane that I'd like to hide if a URL argument exists.

e.g.

Show the pane if the URL is http://www.mysite.com/

Do not show the pane if the URL is http://www.mysite.com/?page=1 or ?page=2 etc

I've tried a few Visibility Rules:

- Is front page
This shows the pane all the time, NOT hides it all the time

- String: URL Path - Allow access on all pages except the following pages: http://www.mysite.com/?page=1 The pane still shows all the time, even on that specific page

- PHP Code: !isset( $_GET['page'] )
This hides the pane all the time, even without the ?page variable...

Before I go through installing Contexts for this single purpose, I was hoping to simply be able to hide this pane using Panels built-in visibility rules. The ?page= variable comes from using the pager in Views.

Comments

cmarcera’s picture

More details:

I added the following PHP Code Visibility Rule to my pane:

if( $_GET["q"] == "home" && !array_key_exists( 'page', $_GET ) ){
  return 'TRUE';
} else {
  return 'FALSE';
}

Then I created a custom content pane below that with the following code:

if( $_GET["q"] == "home" && !array_key_exists( 'page', $_GET ) ){
  echo 'TRUE';
} else {
  echo 'FALSE';
}

In theory, the TRUE/FALSE that the lower pane displays should be the result of the Visibility Rule the upper pane should be following. However when I get a FALSE, the upper pane still displays.

Really baffled on this one...

merlinofchaos’s picture

I think you want return, not echo.

merlinofchaos’s picture

Here's a more efficient version that should do what you want:

return $_GET['q'] == 'home' && isset($_GET['page']);

That will display IF the current URL is home AND there is no pager.

cmarcera’s picture

return $_GET['q'] == 'home' && !isset($_GET['page']);

That ended up doing the trick. I only wanted the panes on the first non-paged page. Thanks!

Parzej’s picture

#4 worked for me also. Thx!

cmarcera’s picture

Status: Active » Closed (fixed)
cmarcera’s picture

Issue summary: View changes

Detailed some terminology