I am using Panel's build-in user/%user page to override the user profile page.
The problem is that drupal's core trigger module and rules module not recognize visits of this pages as visit of user page. There is no problem when I disable overrided panel page.
For example if I visit the panel page http://mysite/user/5 both modules not triggering action on event "User page has been viewed".
If I visit the same http://mysite/user/5 page when panel page is disabled both modules trigger action.
I don't know if it issue for Panels module or for rules and trigger modules. I have opened a bug report also for Rules module #591882: Rules doesn't trigger action when the user page is overridden ,but no answers there.
Comment | File | Size | Author |
---|---|---|---|
#11 | ctools_user_view_trigger.patch | 546 bytes | frankcarey |
Comments
Comment #1
artscoop CreditAttribution: artscoop commentedHi,
Same problem here.
However it works well on overridden nodes.
I don't know much but I'll investigate.
Comment #2
merlinofchaos CreditAttribution: merlinofchaos commentedA quick piece of investigation shows that trigger.module works on hook_user() (I assume rules does as well) which means it will only get triggered if you have the user profile pane. I don't think there's much that can really be done to fix it so this pane is not necessary.
Comment #3
dima700 CreditAttribution: dima700 commentedA small module with implementation of hook_ctools_render_alter and hook_rules_event_info did for me the job.
Comment #4
artscoop CreditAttribution: artscoop commentedHi merlinofchaos,
You're right, I had no time to talk about it here but yes, it works with the User Profile pane.
dima700, can you tell me more about this ?
Comment #5
dima700 CreditAttribution: dima700 commentedmani.atico added here http://drupal.org/node/543012 a small module that adds a "Node panel page been viewed" event to rules module.
I have edited his code to add "User panel page been viewed" event.
This is a module code:
my_ctools_rules.info
my_ctools_rules.rules.inc
my_ctools_rules.module
I am not programmer. It works for me but I will appreciate if somebody can check the my_ctools_rules_ctools_render_alter function.
Comment #6
frankcarey CreditAttribution: frankcarey commentedseems fine, but why create a new rules event, why not just have it trigger the existing "User page has been viewed" event?
Also, is it possible to just invoke the "View" op in hook_user manually so any module using that would work? I'll try that and see if it gets anywhere.
Comment #7
frankcarey CreditAttribution: frankcarey commentedYes, this seems to work fine. @merlin is there anything bad in just doing it this way? If not, would the next step of patching ctools itself make sense?
Comment #8
frankcarey CreditAttribution: frankcarey commentedComment #9
merlinofchaos CreditAttribution: merlinofchaos commentedYou should possibly do some checking on the path to make sure that it's really a page you want to mark the user as being viewed, in case you ever create new pages. For example, user/%user/tracker (should you do that through Panels) might trigger this code but would not count as viewing the user. Otherwise it seems fine to me.
Comment #10
frankcarey CreditAttribution: frankcarey commented@merlin, thanks. I tested with the user/%user/contact page that comes with ctools, and you are right. It does fire the "view" operation when it "shouldn't". From my initial look, user.module doesn't do anything fancy here. It just uses hook_menu to set user_view() as the page callback.
Here is the progression from there
user_view($account) --> user_build_content($account) --> user_module_invoke('view', $edit, $account)
Ctools overrides the page handler and sets it's own, with a fallback to user_view(). I'm testing out adding the code below (new) in ctools/page_manager/plugins/tasks/user_view.inc so that if the fallback isn't used, the core user op will still run.
Comment #11
frankcarey CreditAttribution: frankcarey commentedyeah, that seems to work well now. Patched against 3.1
Comment #12
frankcarey CreditAttribution: frankcarey commentedFYI: user_module_invoke('view', array(), $account); didn't work because of pass-by-reference issues, so I returned to the module_invoke_all
() call in the patch. I'll edit the code above to reflect that change.
Comment #13
frankcarey CreditAttribution: frankcarey commentedhttp://drupal.org/node/305289#comment-2201196
Working correctly for activelyOUT, who is using spaces and context
Comment #14
frankcarey CreditAttribution: frankcarey commentedComment #15
sdboyer CreditAttribution: sdboyer commentedMoving to the CTools, where this properly belongs. This won't cover all cases where the user should be marked as viewed (as some of the approaches in the other comments might), but it will at least mirror core functionality.
Committed.
Comment #16
merlinofchaos CreditAttribution: merlinofchaos commentedWhoops, sdboyer forgot to set fixed when he committed this.
Comment #17
BenK CreditAttribution: BenK commentedJust need to keep track of this thread for reference....