By vivianspencer on
I'm looking at building a new module which produces page content, but I want to be able to add this page to any taxonomy terms that already exist via the modules setting page.
I am kinda new to all of this, can anyone give me any hints
Comments
I've made some headway, I've
I've made some headway, I've added the following code to the module and it successfully displays all the terms for the given vocabulary id
I'm still not sure how to append the page to the term though as the above code doesn't do this
I've read that a better way to do this may be to create a new content type for the module and add this to the list of types associated with the vocabulary. But I'm not quite sure how I'd go about this
any help would be much appreciated
Hi, Can you explain a little
Hi,
Can you explain a little about what you are trying to do? If you are trying to create pages that display vocabulary terms, there are already existing ways of doing that.
Creating a new content and adding it to the list of types associated with that vocabulary would mean the vocabulary would become available as an option for tagging when you create content of that type.
thankyou for your reply I'm
thankyou for your reply
I'm creating a module which takes user input and performs calculations on stock market data; all the data is displayed on a page created by this module.
What I want to do is add the page created by this module to a vocabulary term (attach a tag to the page).
I've read that I can create content types from within a module which I thought might be the way to go as I could then do as you've suggested
Hi, Here is what I think you
Hi,
Here is what I think you are trying to do: You want a settings page that lists all vocabulary terms. You want to be able to choose a term(s) on this settings page, which will then be saved as a setting of term(s) associated with all pages created with your module. The module essentially will be associated with a content type that will add a section of user input on the content creation form that when filled out will create a node. Meaning, the user creates content like with any other type and node 1 is created, do it again and node 2 is created, etc. When these nodes are created you want all of them to be automatically tagged with the vocabulary terms that you set from your module settings page. Does this sound correct? This basically sounds like you just want the taxonomy terms pre-selected?
If so, my thoughts are...
You'll need a form on the settings page that pulls up the vocabulary terms you want so you can choose them. You'll need to save them somewhere. (You might want to just create your own table in the drupal database and store each term ID there) Then, when the content creation form is created you can pull the terms from your table and add the node/term relationship to drupal.
If I understand you correctly, let me know, and I'll try to help you figure out what functions to need to get it working. If not, or if anyone else reading this things I'm way off base, please chime in. If you don't want to do this as a content type that is accessed by going to the "create content" area, you pretty much just need to simulate much of the same things that the create content process does. Creating the node data, accessing/saving the term/node relationship, etc. For example, I believe the taxonomy_node_save() function is what you'll want to use to create the node/term association. You pass it the node id and the terms.
I think you hit the nail on
I think you hit the nail on the head with the taxonomy_node_save() function as I want it to be done all programatically. My problem was actually associating the node created with the selected terms.
I'll have a go with this function and give you my feedback
Thank you