Posted by drubb on July 27, 2008 at 12:43pm
Jump to:
| Project: | Taxonomy Enhancer |
| Version: | 5.x-2.x-dev |
| Component: | Code - Taxonomy Enhancer |
| Category: | support request |
| Priority: | normal |
| Assigned: | Unassigned |
| Status: | active |
Issue Summary
Hello,
I just can't figure out how to save programmatically modified contents of taxonomy enhancer fields. I'm trying to do something like this:
$term = taxonomy_get_term($tid); // Get term object
taxonomy_enhancer_extend_term($term); // Get custom fields
$term->myfield = 'some content'; // Change content of a custom field
taxonomy_save_term(get_object_vars($term)); // Save to database, this doesn't work!taxonomy_save_term doesn't save custom fields, so I need something like "taxonomy_enhancer_save_term". There's something like hook_te_api, but for me a hook is a very special feature, I'd prefer some kind of public function. I can't figure out how to do this, any suggestions?
Best regards,
Boris
Comments
#1
Hmm... You should be ok with taxonomy_term_save...
Try something like:
<?php$term = taxonomy_get_term($tid);
taxonomy_enhancer_extend_term($term); // Get custom fields
$term = (array)$term;
$term['fields']['myfield'] = 'some content';
taxonomy_save_term($term);
?>
It depends what type of field your
term['field']['myfield']is... If its a filtered one then you might need to make "some content" an array instead (array('value' => 'My Content', 'format' => FILTER_FORMAT_DEFAULT))Does this help?