Posted by benone on July 6, 2009 at 8:52am
Jump to:
| Project: | Author Taxonomy |
| Version: | 6.x-1.8 |
| Component: | Miscellaneous |
| Category: | support request |
| Priority: | normal |
| Assigned: | Todd Nienkerk |
| Status: | closed (fixed) |
Issue Summary
Can I achive something like this using this module ?
I need to give each user a term. (from vocabulary called 'Departments')
Then when the user will create any node , it will has a Departments vocabluary term assigned automaticaly, so when I call all the nodes from History Department they will view by this term.
When the employee will be moved to different department the admin will change his Department term, but all the nodes created during his work in previous department will stay as previous department nodes , not a new one.
It seems to be easy , I am just not sure if Author Taxonomy is the right module.
Thanks,
Ben
Comments
#1
benone: This module does not do what you're looking for. Here's the description from the project page:
This module lets you assign multiple authors to a node. Those authors are actually terms in an "author" taxonomy.
#2
I understand now. Thank you for your response.
Can you recommend any module or snippet which can handle the task I described ?
Thanks,
B.
#3
benone: Sure. Check out the User Terms module, which I also maintain.
#4
Thank you. So, I understand when user who is tagged as History Department would create new node, that node will automatically be tagged as Hist. Deprtment by User Terms ?
#5
Hi,
I require similar functionality for my site. I have allowed each user to tag their profiles with a personal tag (the name of that user) and I now need a functionality where by each new content that the user creates will automatically include their personal tag. Could any body recommend a way of achieving this automation? Have you found a solution to your problem, benone?
#6
hey, unfotunately no.
I am still looking for the solution.
Will let you know when find anything and I ask you to do it the same.
Thanks.
#7
Hi benone. I've actually managed to implement what we were talking about!! I'll try and break it down into steps to make it easy to follow:
- As Todd Nienkerk suggested, download and install the User Terms module. This will allow you to associate terms from a vocabulary with your users, by displaying a term selection form on your user's profile.
- Go to admin/users/userterms and set up the form as you require. So in your case the "User Vocabulary" would be your departments vocabulary. Once this is saved users will be able to select their department tag by going to their account page.
- Now you're going to need to download and install the Content Taxonomy module. This module allows regular taxonomy fields to be included as CCK fields, which allows you to set a default value for them.
- When this is ready, add a field to one of your content types of type "Content Taxonomy Field".
- On the field settings form there is a "Default value" drop down menu. We're going to set the default value of this field to the Department tag associate with the currently logged in user using the "PHP code" sub drop down menu. (If you can use this you'll to give your user role permissions to be able to edit this particular field in the permissions section).
- OK there has been A LOT of issues about how to format this field properly to get it to accept your code so here is the code that I used that does the job:
global $user;
profile_load_profile($user);
$current = $user->uid;
$term = db_query("SELECT tid FROM {term_user} WHERE uid='$current'");
$result = db_fetch_object($term);
$result = $result->tid;
return array(array('value' => $result));
Its php code which uses sql database queries to access the User Terms database table and return the tag id that is listed with the user id of the currently logged in user. I THINK that if you just copy and paste the above into the "PHP code" box, then it should work fine for you too. None of it is specific to my case so I think it will work for you.
- In the "Global settings" section if you check the "Save values additionally to the core taxonomy system (into the 'term_node' table)." box, then the default value of the field will be included as a 'proper tag' link at the bottom of the page (which by default it actually does not)
- Last but definitely not least you'll need to select your Departments vocabulary from the "Vocabulary" drop down menu. If this option is different to the one that you set to be the User Terms vocabulary then the default value will be blank.
That should be it! Now if you go to create content of the type you've set all that up for, the field should appear on the create form under the title you gave it with the default value that you specified on your account page. Then when you save the form and create the content, it will be created with that tag as if you had tagged it in the usual manner.
I've given you such an in depth answer because it has taken me AGES to work this out (I had very, very little php knowledge and no sql knowledge before this problem) and I wouldn't wish any one else to go through it! Feel free to paste this to what ever other places are having an issue with the same thing. I hope it works for you, it should do. I'll keep an eye on this thread so let me know how you get on and if you have any problems.
Cheers!
#8
Oops sorry, I'll link you to the two modules I mentioned so you get the right ones.
- Here's User Terms
- and here's Content Taxonomy
#9
WOW! Man, this is great, what you've done here :).
I will try it, coz I need this taxonomy term to be assigned to the CCK Field, not only Drupal Taxonomy.
I found a module - http://drupal.org/project/user_force_term - which let do it without all those steps, you wrote.
But it only put the term to the core taxonomy system.
Tha question to your solution is, can user change the term when creating new node ?
I can't let the user create the node from other Department. :(
I will try this solution and let you know how it works.
#10
Works perfect.
I made it working with User Force Term module, so only the admin can set the users Department.
I removed line
profile_load_profile($user);
from your code, and changed the mysql table name to user_force_term.
What I'd like to achive now, is to set the Select Field inactive ( not invisible ) , for selected Role.
Thanks a lot for your idea!
#11
@benone, use a hook_form_alter to change the selected term to
'#type' => 'value'. It won't be displayed, but will be given to the submit handler.