Hi,

With implementing this great module, thank you for building it! I miss my already available terms.

I implemented cck_taxonomy_ssu with content which is already tagged with taxonomy terms.
I deselected the vocabulary under (admin/content/taxonomy) and selected cck_taxonomy_ssu under /admin/content/types I made cck_taxonomy_ssu field with my content_type.

I am not seeing the terms checked which are already tagged with my nodes.
Am I correct in this issuereport? Am I doing something wrong?
Do I need to import taxonomy fields manual in cck_fields to get this working or is there another possiblility?
If the first, do you have a working suggestion for this?

Thanks in advance for your reply! This is a great module!

Greetings,
Martijn

Comments

summit’s picture

Hi,

I saw the following (otherway around) code on snippr:

<?php 
$i = 0;
$limit = count($field_field_of_interest);
while ($i <= ($limit-1)) {
$tags[] = l($field_field_of_interest[$i]['view'], 'taxonomy/term/'. $field_field_of_interest[$i]['tid']);
$i++;
}
if ($field_field_of_interest){
print t("Fields of Interest") . ": " . implode(' | ', $tags);
}
?>
<br />
<?php 
$i = 0;
$limit = count($field_professional_area);
while ($i <= ($limit-1)) {
$tagsTwo[] = l($field_professional_area[$i]['view'], 'taxonomy/term/'. $field_professional_area[$i]['tid']);
$i++;
}
if ($field_professional_area){
print t("Professional Area") . ": " . implode(' | ', $tagsTwo);
}
?>

Will this help?

Greetings,
Martijn

rconstantine’s picture

The problem is that originally, this module only stored taxonomy terms in the related CCK tables for the node type. These terms are not visible when displaying a node.

Later, I added the option to use these terms as regular tags, but the CCK table versions are still in place.

What you are looking for is importing existing tags into the CCK field which is not presently implemented. You can change this to a feature request if you'd like. It seems like a reasonable feature to add.

Meanwhile, you will have to manually move any existing terms into the CCK fields as well as adjust your node_term table.

summit’s picture

Hi,

Doing it manully is of course ok if there is no script. Could you please state what I exactly need to distribute from where to where.
You are referring to node_term. Is this not arranged when submitting the nodes if the nodes are on the correct fields.

Wouldn't it be possible to get this done by a script? I have 2500 nodes :)
I made a issue about this as you asked for on: http://drupal.org/node/210902

Thanks in advance for your reply and thanks for considering to add this "reasonable feature".
I think this module is great to use for the radiobutton and parent selecting freetagging purposes. I would love to use it on my site.

Greetings,
Martijn

rconstantine’s picture

First, let me correct myself. I said node_term above, but that should be term_node.

As for copying the data, I think you could come up with a SQL query or two that could do it.

The tables that you need that contain your existing data are term_node and node_revisions. From term_node, you need both columns - namely nid and tid. From node_revisions, you need vid which goes with the nid. The trick there is that you want the largest (newest) vid for a given nid.

You then need to move the data to one or more tables for cck. If you have only included the ccktssu field in one content type, then you're in luck since you'll only have to copy data to one place. As I recall, that would be content_field_YOURFIELDNAME where YOURFIELDNAME is the machine-readable name you gave the CCKTSSU field when you added it to the content type in question. This table will have vid, delta, nid, field_XXX_tid and field_XXX_choice where XXX is the same name as YOURFIELDNAME. Don't worry about the choice column for now.

So copy vid to vid, nid to nid, tid to field_XXX_tid, and put a 0 in delta for each entry in term_node.

I think that's it. Whatever you do, backup your data in case I am wrong!!!

summit’s picture

Hi,

I was thinking this over a little bit more. Wouldn't it be easier to change the module so that when a node is edited, the module gets the terms from term_node and places them in the right cck_fields?
So that the modules works ok, the terms are shown clean, and are updated if the user checks this option in the module. The advantage is that this only has to work within this module, so the cck_fields for taxonomy terms are only completely the same as the term_node table if all already available terms in the system are touched by an updating of nodes..

This way everybody how installs this module can use the functionality immidiately and the terms are loaded and updated in both tables only when needed (So it is only adding the reverse functionality as is already in the module).

The term_node table keeps the basic, because of using it to tag the terms and addon updating or new submitting and no SQL converting is necessary, which will scare people of using this fine module in a already running situation. The term_node table needs to be basic for other functionality/module purposes.

If this is not possible I will try above suggestion when I find the time. Thanks for your support until now! If somebody is reading with us and already sees/knows the MYSQL queries which are needed. Please add them to the thread! Also when somebody things of a patch to make the reverse functionality of which is already in this great module, please post!
Thanks!

greetings,
Martijn

summit’s picture

Hi,

I found this peace of code, which may be helps in this pespective. Source: http://www.lullabot.com/articles/quick_and_dirty_cck_imports

I changed it as I think it should be with my fields.

<?php
$results = db_query("SELECT * from term_node");
while ($term_node = db_fetch_object($results)) {

// I was converting old style nodes to CCK nodes.
// If you're building them from scratch you would
// want to use: $node = array('type' => 'story'),
// where 'story' is the type of node you want to
// create.
$node = node_load($term_node->nid);

$values = array();

// You'll recognize this as the structure of
// form_values you'll see in a submit or validate
// handler. You're basically building it manually,
// rather than using $_POST from a user.
$values['tid'][0]['value'] = $term_node->tid;

$i = 0;
$cck_tax_ssu = db_query("SELECT field_cck_regio_tax_ssu_tid FROM
TREKWORLD_content_field_cck_regio_tax_ssu WHERE nid = %d ORDER BY weight ASC",
$term_node->nid);
while ($ing = db_fetch_object($cck_tax_ssu)) {
$values['field_cck_regio_tax_ssu_tid'][$i++]['value'] = $ing->field_cck_regio_tax_ssu_tid;
}

// Multivalue CCK fields are handled this way --
// the name of the field, then a numerical key for
// each individual field instance, then a 'value'
// key. Single-value fields are actually handled
// the same way, but they only have the '0' delta.
//
// Add Martijn: For this purpose vid, delta, nid, field_XXX_tid and field_XXX_choice necessary
//
$values['vid'][0]['value'] = $term_node->vid;
$values['delta'] = $term_node->delta;
$values['nid'][0]['value'] = $term_node->nid;
$values['field_cck_regio_tax_ssu_tid'][0]['value'] = $term_node->tid;
$values['field_cck_regio_tax_ssu_choice'][0]['value'] = $term_node->tid;
$values['status'] = 1;
$values['promote'] = 1;
//
// 'term_node_node_form' would be 'weblink_node_form' or
// whatever node type you're creating.
drupal_execute('term_node_node_form', $values, $node);
}
?>

Should this may be work? If so, could you may be put it in the module, so it works for everybody?
I have to little experience on programming to know exactly what is the above code doing .
I think it is getting the terms when I update a weblink nodetype node, right?
How can we make it nodetype independent? How can we make it cck_field name independent.

I think those steps have to be done to build it into your great module!
Thanks in advance for your reply!

greetings,
Martijn

summit’s picture

Hi,

I would love to try to do it myself, but I can't find the line in your code where I have to insert above stuff so hopefully the taxonomy terms which are already connected to a to be updated node are shown as checked values in the radiobuttons.
Please assist. Thanks in advance!

greetings,
Martijn

rconstantine’s picture

I commented via the email you sent.

summit’s picture

Category: bug » feature

As asked, made a feature request of it.
Any one who likes to use this with already available vocabulary, please participate :)
Thanks!
greetings,
Martijn

summit’s picture

Hi,
I follow your advice and want to copy the terms to the cck fields table to be able to work with this great module on my already available vocabulary and taxonomy terms.
As you described I need to copy term_node and node_revisions.
In pseudocode I need
1)
Select t.nid, t.tid, n.vid from t term_node n node_revisions where t.nid = n.nid
==> How do I get the newest vid for a given nid please?

2) Then:
Insert into content_field_cck_tax_ssu
Values vid, delta, nid, field_cck_tax_ssu_tid and field_cck_tax_ssu_choice

So should I copy

n.vid =>  vid.content_field_cck_tax_ssu
n.nid =>  nid.content_field_cck_tax_ssu
t.tid =>  field_cck_tax_ssu_tid .content_field_cck_tax_ssu
0     =>  delta.field_cck_tax_ssu_tid 

Could you please provide the SQL for 1) and 2) conversion? It looks quite complicated and may be for you easy to handle. If so thanks a lot in advance!

Greetings,
Martijn

summit’s picture

Hi,

I was wondering. Could the copying from term_node and node_revisions also be done with http://drupal.org/project/cck_taxonomy ?
Or http://drupal.org/project/node_import ?

I try to figure out a easy way, because I have more than one website on which I want to use this great cck_taxonomy_ssu module?
Please respond!

Thanks in advance,
greetings,
Martijn

summit’s picture

Hi,

I am trying to get the SQL running. This is what I got so far:

SELECT n.vid, t.nid, t.tid FROM node_revisions n, term_node t WHERE  n.nid = t.nid AND [latest] (n.vid)...

How to get to the latest vid in node_revisions. What MYSQL command could I use for this?
Do I need to use http://dev.mysql.com/doc/refman/5.0/en/getting-unique-id.html somehow? And how can I implement this then in my MYSQL statetement?
Ryan, somebody any idea?
EDIT: should it be:

SELECT n.vid, t.nid, t.tid FROM node_revisions n, term_node t WHERE  n.nid = t.nid AND MAX(n.vid);

or

SELECT MAX(n.vid), t.nid, t.tid FROM node_revisions n, term_node t WHERE  n.nid = t.nid;

MAX(n.vid): is that the right command in this case? What query is correct?
And how to proceed to get these values in cck?
Thanks a lot in advance for your reply!
Greetings,
Martijn

rconstantine’s picture

MAX is the correct way to get the largest (newest in this case) value. As I stated before via email, I don't presently have time to figure this out for you. I estimate this would take me about half an hour and I just can't spare that at the moment. Perhaps in a few weeks once I get some projects out of the way. Bothering me repeatedly via email is not going to magically clear my schedule. If you need this done quickly, then I suggest you get a book on MySQL and PHP as well as study the schema for the modules you have installed. If you're a web developer, then I'm not sure how you're surviving without these basic skills. If you aren't, then it won't kill you to learn something new. You won't benefit from just hacking one bit of code, you need to learn the whole subject. If you're a decent reader, you could learn all that you need to know in just a couple of days. In fact, had you picked up a book when you opened this issue, you'd have been done already. Now, back to work for me. TTFN.

summit’s picture

Hi Ryan,
Sorry if you think of my emails about my progress in this as bothering. That was absolutely not intented. I thought you could give me the latest swing after my indeed thorough reading last days. I am not a programmer and try my best to cope.
Again sorry, I will not bother you about this again per email. As stated it was not intended to bother, but to show progress..

This is what I did so far.
0) First empty the table field_cck_taxonomy_regio_ssu to start from scratch and then use module: http://drupal.org/project/revision_deletion to have only the latest revisions available
EDIT: I couldn't find another method to get to the right revisions and not getting to little terms back
1) Then I build up the SELECT statement in SQL:
SELECT n.vid, t.nid, t.tid FROM GR_node_revisions n, GR_term_node t , GR_term_data td WHERE n.nid = t.nid AND t.tid = td.tid AND td.vid = 138;
Vid 138 is my vocabulary
Then I got a list of n.vid, t.nid and t.tid to import in my content_field_cck_taxonomy_regio_ssu table

2) I build in SQL the formula to create the correct SQL insert statements as described on: Step 2 at http://drupal.org/node/133705

The Excel formula I think is:

="INSERT INTO GR_content_field_cck_taxonomy_regio_ssu  VALUES (" & A2 & " , " & C2 & ",  " & B2 & " , " & C2 & ", NULL);"

Ryan, with putting 0 in delta I got SQL errors, I saw that the cck_taxonomy_ssu module gave also the tid's as values in the delta, thats why I made the sql like this.

To have this formula working you have to set the SQL-resultlist in the columns A, B and C from A2, B2 and C2 and further down.

3) Then copy the formula down just a column to the right next to the columns A, B, and C. I did it in column E.

4) Then copy the Formula output and paste it in MYSQL in the SQL tab on the table GR_content_field_cck_taxonomy_regio_ssu (in my case this is my table)

5) Clear your caches.

Thanks for your advise how to deal with this Ryan!
Thanks again for your reply while you are so busy doing something else, very much apprechiated. Again sorry to disturb you but this solution works fine for the moment I think!

greetings,
Martijn

summit’s picture

Status: Active » Closed (fixed)

Issue closing, short term solution above (http://drupal.org/node/210301#comment-704247)