Closed (fixed)
Project:
Domain
Version:
5.x-1.0
Component:
- Domain User
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
1 Mar 2008 at 19:59 UTC
Updated:
9 Mar 2008 at 20:29 UTC
I have been working on a project that would be most beneficial to have easy access to the domain_user variables inside of blocks. Where I could just print the variable out using some php.
I would like to see if anyone else could see the benefit of this feature. I can not believe it would not be useful to most.
Thank you in advance for the responses.
Comments
Comment #1
agentrickardrc4 is no longer supported.
I don't know exactly what you are asking for.
The $_domain variable is a global variable which represents the current active domain, and domain_user implements hook_domainload() to attach the UID (user ID) to the $_domain array. This is created during hook_init(), so all of the domain_user data is available to you at any point in the page load cycle.
I suspect you want something like this for checking the current domain:
If you need to pull all domain information into a block, use domain_domains().
The module has been carefully designed for extensibility.
Please see the API documentation and section 6.2 of README.txt
Comment #2
ygg commentedThat would be great if I could just plug that in and go. Maybe I just don't understand this, but I can't get that to do anything. It won't get any of my Domain User info or anything.
Also, I did upgrade to 5.x-1.0 sorry I had missed the update.
Comment #3
agentrickardYou need to be more clear about what you mean by "my Domain User info."
That code doesn't do anything because there is nothing inside the IF loop except a comment where you can put the code you want.
Comment #4
ygg commentedRight, I understand I had to put something in there. The "my Domain User info." I meant was the profile fields that I have added. I can get them in the page.tpl file, but not into the block.
What would I need to put inside that block? I put a print $domain_user->profile_field_i_made; inside of it, but that did nothing. I tried some other things, but seemingly got nowhere.
What i'm saying is maybe that the same $domain_user->profile_field_i_made; snippet of code I'm able to use in the page.tpl would also be accessible in a block.
Comment #5
agentrickardYou have to create the full $domain_user object with user_load on the UID, taken from $_domain['uid'].
Then run a profile_load_profile().
http://api.drupal.org/api/function/profile_load_profile/5
http://api.drupal.org/api/function/user_load/5
Something like:
It would be very wasteful to do this in the main code any time a domain is loaded.
Comment #6
ygg commentedI guess i'm just dumb...I can't figure this out at all.
Here is what I have so far and all I want is to pull a created profile field into a block.
I'm probably way off with this. I'm not much on PHP, but trying to learn more. All I know is the process it needs to do maybe, but not how to get it to do it.
Thanks for the help in advance.
Comment #7
agentrickardRight. You are mixing the two code snippets. Read up on PHP global variables.
You just want to grab the user of the _current_ domain, right?
So use:
Comment #8
agentrickardMight be a nice feature for a later release.
Feature request welcome.