By aegreen on
Is it possible to automatically tag a node with it's title?
For example I have NAT setup to make a term based off the title of a node and I am wondering if at the same time that node can be tagged with the freshly created term (i.e. the title)?
Doesn't seem like something that could happen simultaneously i.e. the node is created -> term is created -> node is tagged.
Anyway to make the term is created -> node is tagged step automatic?
Comments
I don't know of a direct
I don't know of a direct solution, however, you could try to do it with a computed field, and do it with php, thus a solution would be template independent.
Paul K Egell-Johnsen
Doesn't NAT do that out of
Doesn't NAT do that out of the box? Perhaps NAT-NG does?
Paul K Egell-Johnsen
Would think so
I thought/think so but I'm not sure how to configure it - nor what the difference between NAT and NAT-ng.
Right now I have NAT-ng installed and the settings are as follows:
Vocabularies:
(Selected)People
Creating a node of type roster_profile will automatically create a term in any selected vocabularies.
N Associate node body with term description.
Y Delete associated term if a node is deleted.
N Delete NAT-ng node when a NAT-ng term is deleted.
N Allow users to define synonyms and related terms when they create and edit nodes.
N Make NAT-ng terms in roster_profile node views point to the associated node rather than the taxonomy page.
(Y = checked box, N = unchecked box)
I think this page might give
I think this page might give you the general idea of how to do this with token and some code. http://blog.adyax.com/2009/02/english-drupal-tutorial-auto-tag-with-token/
This line in the first code block:
should use the token [title] only, like thus:
And then you need to just use a more proper name. Unfortunately the tutorial is used to create a module, so you have to paste the code into your_module.module. In addition you will need a your_module.info file for letting drupal recognize the module.
BTW, I think this solves a similar problem I have, or at least partially. I have not tried this, I just found it by the way of a few directed searches.
Paul K Egell-Johnsen
Thanks I had stumbled upon it
Thanks I had stumbled upon it before but couldn't understand it so I passed it by. I just tried implementing though as per your instructions but unfortunately I have never made/edited a module before so this is all new to me and I am stuck.
I created a folder called "autotag-token" and placed autotag-token.info and autotag-token.module in it and in my modules directory and was able to enable it. BUT I don't know where to go from there. I can't seem to find the form/settings for it in the administration menu or when I edit a content type.
This is the code in each file:
autotag-token.info
autotag-token.module
Thanks again for all your help. I'm sorry I'm such a newbie.
Alex
We've all been newbies. I
We've all been newbies. I still am when it comes to writing modules, I haven't actually done so yet :)
You also need to add to the autotag-token.module the following code:
I do not know where the form will reside, try the following paths:
/admin/build/token_autotag
/admin/settings/token_autotag
But, it doesn't really matter, because the above code would probably replace it with title anyway! At least at a cursory glance I think so.
Paul K Egell-Johnsen
I will test this on my own
I will test this on my own develop server tonight, there is a bug in the code as noted in the comments on the original page, but I can't see how the supplied bug fix will work in all instances.
Paul K Egell-Johnsen
Here is a module which is working
I never found the form which is created :P
autotag_with_title.module
autotag_with_title.info
It only works with the FIRST taxonomy (id 1).
Improvements would be:
a) add the form and settings to the Taxonomy type.
b) add the option to configure which specific node types should be autotagged
c) add the option to autotag with different tokens for different node types (to solve a different Use-Case where nodes referencing the created node can add the name of the referenced node as the tag, and not their own titles).
d) add a form for configuring per nodetype and per taxonomy (a matrix, in other words), much like pathauto.
Paul K Egell-Johnsen
Thanks for all the help Paul.
Thanks for all the help Paul. I tried it but alas I still can't figure it out - I think I can't get autotagging to work at all actually.
BUT I found a solution!
I made a Trigger Rule. It will load the content type 'Roster Profile' when it is saved, then load the vocabulary that I have made - 'People', then add a term from the contents Title and then add it to the content. This avoids the need for NAT at all (except it doesn't remove the term - but I don't see a problem with that).
Cool. I will look into doing
Cool. I will look into doing this, and perhaps it will solve some other use-cases.
Paul K Egell-Johnsen
Heh -- whoops. See my comment in the main thread.
It was attached to the main thread instead of here...
http://drupal.org/node/864674#comment-4063828
...essentially, thanks for the info and idea about the rule. I successfully adapted it and used it to redefine some site workings on a client site, enabling me to utilize taxonomy instead of a couple of CCK fields. Much cleaner outcome. Thanks!
This is a very useful rule - thank you for posting it.
I just adapted it to a site and eliminated the need for a couple of CCK fields that I can now better put to use via Taxonomy.