I want to expose the current user as a context, i.e. automatically pass the current user as an argument into a panel so that it can be passed from there into my respective views. I've searched everywhere I could think of, but am unable to find any solution to my problem. Am I missing something simple?

Please note: I'm NOT trying to limit access to panels/variants, but even if I did want to, this still would not solve my problem of passing the current user as an argument into a panel.

I tried using combinations of 'me' alias, URL alias and a manual menu entry (after temporarily hacking out the menu validation) to 'path/me' (where the panel path is 'path/%user') but I get a "Page not found." error.

The closest I've come to a solution is using PHP to pass an argument into the views referenced by the panel, but this is clumsy (it corrects the problem downstream and kind of defeats the purpose of having contexts in the first place) and does not work for all my panes/views. Furthermore it requires significant duplication of some views AND panels, seeing as I want to be able to pass ANY user (incl. the current one) as an argument into a view. If I use the PHP argument method, I would need to duplicate all these views (have one with a normal argument and one where the argument is automatically passed) and have seoarate panel variants. Like I said: that kind of defeats the point of having contexts.

I've noticed that "logged in user" is exposed in the Access subsystem, but not in the Context subsystem. Would it be easy to port? Alternatively, what about allowing PHP-arguments in panels?

Does anyone have any advice? I desperately need this feature and have all but given up. This is quite a significant absent feature IMHO.

CommentFileSizeAuthor
#17 ctools_current_user.patch1.4 KBcrea

Comments

H3x’s picture

Title: Expose current user as context » Expose current user as context/pass current user as argument into panel
merlinofchaos’s picture

I've been thinking that current user needs to be an automatic context on all pages, not just in the access system, so will try to work on this at some point.

H3x’s picture

Your effort will be HIGHLY appreciated. Any guess as to a time frame? Or any else willing to work on this as well?

merlinofchaos’s picture

I don't think I'll get to it before the full release.

szadok’s picture

When is the full release scheduled?

manuel garcia’s picture

Version: 6.x-3.0-rc1 » 6.x-3.x-dev

Deffinetly would be nice to have this. It would greatly increase the possibilities... think switching the frontpage for logged in users based on their information...

anxious to test anything that comes up here!

sagannotcarl’s picture

I agree this would be great.

I also would be happy to test this as I have a couple places I've wanted this and could try it out.

sdboyer’s picture

Project: Panels » Chaos Tool Suite (ctools)
Version: 6.x-3.x-dev » 6.x-1.x-dev
Component: Plugins - contexts » Code

This request has been made in the CTools queue as well (which is where it properly belongs), but this is longer/older, so marking that one duplicate.

crea’s picture

Subscribing

tobi20’s picture

Subscribing

vir_2’s picture

Subscribing

summit’s picture

Status: Active » Closed (duplicate)

Hi, Sam said this was duplicate, so making as such. Greetings, Martijn

crea’s picture

Status: Closed (duplicate) » Active

"Making that one duplicate". "That" is duplicate of "this". And by "that" he meant #609082: Please provide current user context

crea’s picture

Any updates on this ? Imho this is really critical: without this feature you can't really have Panels as replacements for all pages, because you can't use user context for showing dynamic content depending on current user on pages with path not containing an argument. So no user dashboards, no individualised pages etc.
Sure you can use "Views" panes where View user argument defaults to current user, but this is ugly and works only for Views. Other panes that work with contexts won't work this way.

Atleast give us some hints how to implement a context plugin that doesn't require an argument to work. With current Panels UI I can't even add a context unless I have argument in the path.

merlinofchaos’s picture

Yes you can. You have to do it per variant (There's the contexts tab) -- and a good example to start from is plugins/contexts/node.inc

crea’s picture

Indeed. Previously it didn't work for some reason. Will provide patch soon.

crea’s picture

Status: Active » Needs review
StatusFileSize
new1.4 KB

Attaching patch that implements that feature in slightly different way. User context now can be added manually instead of being assigned to an argument, providing current user object.
Tested this together with another user context assigned to argument to ensure they coexist successfully.

merlinofchaos’s picture

Status: Needs review » Fixed

Significantly improved and committed.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.