By divrom on
Is there a way to specify if custom Panels appear just for logged-in users, or alternative ones for anonymous users, etc?
Is there a way to specify if custom Panels appear just for logged-in users, or alternative ones for anonymous users, etc?
Comments
use blocks plus a bit of code
put your content into blocks, place them where you need them then use a bit of code to set their visibility, you can find the code here
http://drupal.org/node/83500
be mindful the code is swapped around
cheers
In the panel, or the block?
Thanks, Sean.
So, do I put the code in the panel, or the block? It hasn't work when I've tried.
In short, 'No', you can't
In short, 'No', you can't block the viewing of a panel by role. But you can be have some workarounds.
You would do this for the blocks, as above and denied the content of a block. You can also set any included views to only be viewable by certian roles.
In a sense, they can see the panel, but all the content of the panel is denied to them (either by views or by blocks). If you have custom content or nodes displayed, they will still show.
----------
My Drupal/Tech Thoughts
vbDrupal Articles at Skejo.com
Shame you quite swap blocks
Thanks, folks. Really useful.
A couple of my panels have background images, so they're now showing up. It's a shame that there's no way to have one block show up for logged in users and another for visitors.
I thought that I could do this as the first and second wouldn't show and would be replaced by the third and fourth, but unfortunately I've got two empty images with the two replacement panels appearing below.
Can either of you think of a way round this?
Use the php code in the visibility settings
Go to the "Page specific visibility settings" after you've put the content into the block.
Select the "Show if the following PHP code returns TRUE (PHP-mode, experts only)." setting and then put the code in.
The code turns it on or off for visitors and authenticated users.
no way to hide a panel page from an anonymous user?
Is there no way to do this? I have TAC installed and can hide all the content from the panel page, gut the panels show up empty...i would much rather have a '403' error than this...
4.7
j
It is possible
It is very much possible to do this if you don't mind a little coding.
Open up your panels.module in your favorite text editor. Proceed to line 679 where it should read: (or just do a search for this)
This is where we will edit. The first 4 lines are what we need to change, from this:
To this:
What this does is find if the user id is anything greater than 0 (logged in) and if so, loads the panels per normal. If not, the access denied page will be shown. Now, this only detects 2 things...signed in and signed out...it does not give access based on roles.
It could be modified to allow access based upon role as well, but that might prove to be a little more work. Hope this helps!
Cheers!
Sadly the above only works
Sadly the above only works if you want to just use panels on authenticated users, if you have several panels, some authenticated some not this won't work, is there a way of adding an array argument to the above to specify specific panels?
In short, no. I'll tell you
In short, no. I'll tell you this is completely possible, but this is more of a feature that must be added to the module as opposed to a simple code hack. Another option when configuring the panel is required to say whether you need to be authenticated or if the page is accessible by anonymous users. This would mean a new database entry will be required as well, OR you can do a really bad hack like this:
Which essentially allows anonymous users to access panels with the title set to "anon" but they will not be able to access any other panel. It works but like I said, its a HORRIBLE hack and this also will show "anon" at the top of every anonymous page. That title could be removed but its put in place by drupal itself and would then start to become VERY ugly, more so than it already has. This feature I am assuming will be added in a future release anyway as this bit of code suggests:
You could attempt to implement your own authentication methods in there, but I think you will find it VERY difficult without the added options on the panels config page to specify what user groups have access. If I had the time, I might be inclined to add this all in but the developer is most likely working on this feature and will more than likely look a hell of a lot better than mine. Patience is key. If you can handle the "anon" being at the top of some pages then you can just use my code until such a time this feature is released. Also, if you want to change the title for anonymous pages, you can simply change where it says "anon" to whatever you want so long as the title for all the anonymous panels is that exact same string.