Download & Extend

Visibility based on URL Argument

Project:Panels
Version:7.x-3.3
Component:Panel pages
Category:support request
Priority:normal
Assigned:Unassigned
Status:closed (fixed)

Issue Summary

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

#1

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

#2

I think you want return, not echo.

#3

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

<?php
return $_GET['q'] == 'home' && isset($_GET['page']);
?>

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

#4

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!

#5

#4 worked for me also. Thx!

#6

Status:active» closed (fixed)
nobody click here