Hello all,
My objective is to allow a user to add new nodes to a section of the site, and have those nodes automatically pre-populated with the appropriate taxonomy term.
For example, the user would click an 'add content here' button, which would point to /node/add/flexinode-1 ... and the node form would be displayed. I have set up taxonomy so the user can select the appropriate term from the drop-down list. However, I would like to be able to set the drop-down to a default based on the context of where they were when they clicked 'add content here'.
I assume that the URL for the 'add content here' button would include some sort of parameter (like term=something) so that the node form could be aware of which section the user was adding the content to.
Any ideas on the best way to approach this? Should I try to modify the _taxonomy_term_select() function in taxonomy.module? Not sure where to start... any direction would be helpful.
Thanks,
Chud
Comments
There is a taxonomy_default
There is a taxonomy_default module that does this, I think. Sorry for not giving the link but a quick search should pull it up for you.
thanks
Thanks Ramdak. This is interesting, but I don't think it will help me to dynamically set the default based on the context of the site.
not pretty... is there a better way to do this?
After messing around a bit I came up with the following solution, although there must be a better cleaner way.
1. Created the following link to create a new node: /node/add/flexinode-1?default=mydefault
2. I then inserted the following code into taxonomy_form_alter() in taxonomy.module
...just before this statement...
The result was that the Category field was pre-populated with the value of $_GET['default'].
Note that I am using 'free tagging'.
Can anyone provide me with direction on how to properly implement this?
thanks
Thanks chud, you helped solve my problem!
Just for 4.7 ? what about 4.6?
Hi There
I am using 4.6 and I want to do the same look here http://drupal.org/node/62965
I found the taxonomy default but it not suitable for 4.6
the code here is just what i need will this work in 4.6 ? , I guess not
Can you tell me what to change in order it to work in 4.6 ?
Thanks , Avior
Non "Free Tag" version
If you are trying to do this with a selector. Put this line:
Ahead of this block:
And use the category id in your link:
/node/add/flexinode-1?default_id=555
The solution was great. I
The solution was great. I applied it for the Image content type. But the link that I had to give to the add node was not http://../../../?q=node/add/image?default=termname... When I first used it, it went to the page where all the content types were listed. So instead I used ?q=node/add/image&default=termname. May be this is useful to someone. :)
FYI : I am using D6