I'm mostly using FBSS as an api, doing all my display with Heartbeat module. However, I'm using the 'facebook_status' block in order to let users post statuses.
I want users to be able to post on other user's profiles, however I'm using content profile, not core profile module. So, essentially I'm trying to find a way to render the form, but manually pass in the context (which I'll get from the $node->uid of the node I'm viewing). How can/should I do this?
Essentially, I'm trying to get the same functionality that's offered 'out of the box' on core user profiles, but instead I need to set my target user (in the context) by passing in the node author....
thoughts?
Comments
Comment #1
icecreamyou commentedYeah, I thought about making this into its own context when I was writing the default contexts. That's what you'll have to do -- you'll need to write a new module that adds this as a new context. Here's your .module file (sans closing
?>):If you need to use the status update form on other pages with other node types and you don't want this context to apply on them as well, you can either add a check to the is_applicable() method of the facebook_status_node_author_context class or you can edit the context's settings and change where it applies that way.
I'll think about making this available as a default context. For me to do that I would want a way to have contexts "disabled" by default so I'd need to add that feature first but I think it would be a good idea.
Comment #2
Rob_Feature commentedYou rock :)
This is exactly what I need...however, I'm getting an error in the custom module which is:
Thoughts? I'm not familiar 'extends' as in: extends facebook_status_user_context
so I'm not sure how to bugtest.
Comment #3
Rob_Feature commentedTried adding
module_load_include('inc', 'facebook_status', 'includes/utility/facebook_status.contexts.inc');without success...it seems like if I just include that file it should find the function?
Comment #4
icecreamyou commentedOh, sorry. Yeah, unfortunately you need to add that line in the main body of the file to include FBSS' context file. You may also want to put the class in its own file (with the include of facebook_status.contexts.inc at the top).
Comment #5
Rob_Feature commentedSorry, not sure I follow. I tried to do the module_load_include shown above, but it doesn't work. I still get the same error. Can you clarify what I should try next?
Comment #6
icecreamyou commentedEXAMPLE.module:
EXAMPLE.contexts.inc:
Comment #7
Rob_Feature commentedThanks for going the extra mile on this...unfortunately I still get the same
Class 'facebook_status_user_context' not founderror when clicking configure next to the context, but I'll keep working to see if I can figure out why it's not finding that in the FBSS inc file...Comment #8
Rob_Feature commentedJust doing some reading on "extends" (which I dont know anything about) and I think this error may be actually related to facebook_status_user_context() not being 'defined' before being extended. I'm not totally sure what that means (or how to define it) but I've read a few posts that if it's undefined it'll give a 'not found'....
This from php.net:
I'm going to see if I can figure out how to "define" that function before I extend it...
Comment #9
icecreamyou commentedIt's a class, not a function: http://php.net/oop
And that *is* the reason for the error but I don't know why that class wouldn't be available if the correct file was included. Try using require_once instead of module_load_include().
Comment #10
Rob_Feature commentedit turns out the 'not found' was becuase my include was wrong. It should be
module_load_include('inc', 'facebook_status', 'includes/utility/facebook_status.contexts');not
(note the extra .inc at the end of the filename)
Although, now that I have no errors, posting on the content profile still doesn't give a target..hmmm....
Comment #11
icecreamyou commentedJust having the context in your system might not be enough -- you probably have to go to admin/settings/facebook_status/context and make sure that the new context takes priority over the User Profiles and Nodes contexts.
Comment #12
Rob_Feature commentedYou, my friend, rock.
All good! The user profile must have been taking priority, it all works now. Thanks for your help and the great module!
Comment #13
icecreamyou commentedCool. Glad it works.
I'm going to hold on to this then... will consider committing it.
Comment #14
icecreamyou commentedPostponed pending #1261720: Allow disabling contexts
Comment #16
capellicI had the below all typed up when I discovered I forgot the change the path for my include path:
But thought I'd post this anyway just in case somebody else had the problem.
---
When I try to save the configuration page and give the node author priority, I get the white screen of death with this error:
I went into the facebook_status_contexts table and manually changed the weights so that node_author is -3 and user is -4. Then the fatal error when away, but now I'm back to square one-- the context is never hit, user is taking priority.
I thought this might be a module weight issue-- but tried 100 and -100 with no luck.
Comment #17
capellicI got this working, but since I'm using panels, Drupal does know about a path that isn't node/[nid] -- it's member/[name]. Here's the context include file code:
Comment #18
icecreamyou commentedcheck_plain() and other filtering functions are only for use on output (i.e. when displaying information). Using it on input can sometimes cause incorrect results.
Comment #19
capellicThanks for the tip.
And I was wrong about needing to change the code-- your example syntax is fine. Long story. :-)
Please disregard the previous version of this comment that reported that the context configuration pages were always showing node author. I discovered I had some errant debugging code that was causing the problem. Sorry if you spent any time on this.
Comment #20
icecreamyou commentedNow that #1261720: Allow disabling contexts has landed we can finally look into getting this committed.
Comment #21
icecreamyou commentedUntested patch attached. (Make sure to enable the new context before testing.)
Comment #22
icecreamyou commentedOne thing I forgot to put into this patch is all the places Statuses checks for
type = 'user'where it should now check fortype IN ('user', 'node_author')(or$type == 'user' || $type == 'node_author'). While this mostly won't affect the user experience, we need to go through the many places this check exists and see if it needs changing (hook_user_delete() is one example). I'm okay with addressing this as a follow-up though.Comment #23
icecreamyou commentedPer #22, attached is a list of everywhere that might need changing.