Panel blocks display based on url selection rule
Problem:
I needed to create alternative panel page layout based on my url. Some of the content would not be used for the mobile site and needed to disappear. I had created a mobile site with the m. prefix and then change my layout based on whether the user was visiting from a mobile device. (the m. site )
(To configure you mobile theme switching and configuration check out http://cruncht.com/419/mobile-drupal-site-setup/ )
Solution:
- Navigate to the content of the panel page you would like to change.
- On the panel you want to remove select the gear in the right hand corner -> select visibility rules -> add new rule
- Select php code.
- then add in the PHP code text area
- Save it and you're done.
return $_SERVER['HTTP_HOST'] == ' MAIN SITE URL HERE (foo.com)';
/**
*UPDATE
*/
You can also base this rule on the theme. Most likely if you are using this approach you will be using 2 themes, in which cause the visibility rule goes against the theme and *not the uri so youu would have
return $theme == 'THEME-NAME';
Now that panel has to have a url of foo.com for it to be seen. You can change the order if you have a panel that you only want to be seen on the m.foo by just added that mobile site url.
Help improve this page
You can:
- Log in, click Edit, and edit this page
- Log in, click Discuss, update the Page status value, and suggest an improvement
- Log in and create a Documentation issue with your suggestion