By mrynearson on
Hi:
I'm have a content type which is using both CCK fields and taxonomy terms. I'm trying to show both the fields and taxonomy terms in the node view. I tried to use the template to do this but I didn't see a way to do this readily. I ended up deleting the CCK template and creating a node template for the content type. I can list out the taxonomy terms this way but I don't see how to break them down into the respective vocabularies. I did dig around the drupal tables and saw the VID and terms listed in various tables but it seems like it be a major SQL ordeal to get the data that way. Appreciate any help or direction on doing this.
thanks!
Comments
CCk vocab question follow up
well got no replies, it seems like something that might be common. Perhaps I should be more specific.
I have a cck form, half with custom fields and 5 or so taxonomy fields. Some are multiple choice and not all are required. What I want to do is show all the values in the node view, with some HTML for headers and labels.
Displaying the fields is straight forward but displaying the taxonomy terms are what I'm finding difficult. I'm not a php guru but i usually hack my way thru it.
So I found the following snippet online which lets me display all the terms:
So this displays all the terms with comma's but no way to seperate into the appropriate vocabulary. I did determine I can weight the Vocabulary so I know the basic order of the terms but since there are multiple choice hard to know where terms for one vocab begins and the other ends. If I had only one term per vocab then I could assume $term_links[0] is the term for the first vocab, $term_links[1] ids for the 2nd vocab etc.
My question did for any php/sql/drupal guru is what kind of query would yield the results I'm looking for . I see the vid and nid in various tables but I don't see an easy way to grab the terms for each vocab and present them.
Thanks for any help
Marty
Did you find a solution to
Did you find a solution to this? I am looking to do the same thing. I have cck fields address, city, state, zip, but I want these to be categorized, so I need to create categories. I don't want users to have to fill in info twice, so I will create categories and drop the cck fields. BUT, problem is, I want the new tax fields to show.....
~~~~~~~~~~~~~~~~
Kris
Current project: www.cribfax.com
try this
Hi Marty,
Sorry I haven't seen your post till now, but you may find http://drupal.org/node/53089#comment-111458 useful.
I modified the code from the above post slightly so that I could put it as a function in my template.php file:
Don't include the first or last lines of the above when pasting into your template.php file.
I call this function from inside my node-content-cckname.tpl.php using
print node_terms_list($node);Jeff
_________
http://marmaladesoul.com
Awesome
thx!
Does this work in Drupal 6 with the Nitobe theme?
Hi, I'm trying to achieve something similar to what is described in the original post in Drupal 6 using the Nitobe theme and a CCK custom content type. I want to display Taxonomy terms when viewing a node as if they are fields in the node.
I've pasted your function into the Nitobe template.php file, then called the function as you demonstrated from my custom node (CCK) template. However, the terms are not printing out.
Calling this Nitobe function does output the terms, however:
But when I try to change the separator to cause a break between each term, I seem to break the code. (The browser won't display the page.)
Please advise. Thank you!
Nice function to make it work
Nice function to make it work on drupal 6.19 you have to change it to this one:
The way to call the function is obviosly the same:
cck and vocabularies
Maybe creating a cck vocabulary field is a better idea, instead of using the taxonomy association directly. Then you can template the fields easily.
I did a similar thing when playing with profiles pre-cck,pre nodprofile.module, and now I'm thining of writing a cck field for vocabularies. Advantages would be:
i ) being able to choose output better on a per node-type basis (multiple values, checkboxes/radios)
ii) field ordering and output templating.
I'm not that strong with cck but I am thinking of giving it a shot next week.
EDITED:
I just realized of course that this will remove the straight forward category association which can be quite handy (but maybe that's usefull too.)
James