Posted by hemant_gautam on January 10, 2013 at 7:26am
Hi,
I have created vocabulary and its terms. I want to export it using features modules. I am able to export only vocabulary name. but its terms are not coming in exported files using features. And there no such modules I found to export taxonomy in Drupal 7.
Same thing I have to fo it with menu and its links. I am able to export only menu name. but its links are not coming in exported files using features.
One more query--
I have created one role called editor and assigned some permission to that role. I am able to export roles properly but permission are not assigning to that particular role even permission names are coming in exported files using features.
Please help me.
Comments
Try Features Extra module
http://drupal.org/project/features_extra
Dude, I have tried with this
Dude, I have tried with this features_extra module.
I have sorted out all the issues except vocabulary. I am able to export vocabulary name only but not its terms.
Provide your suggestion.
I'm running into the same
I'm running into the same problem. I've seen some things pointing back to uuid_features; however, installing uuid_features throws an error on Drupal 7.19.
I have exactly the same issue
Regards
I had a similar issue with
I had a similar issue with taxonomy terms. My understanding is that Taxonomy terms are entities, not configuration, and therefore outside the scope of Features. (Although yeah, they're just taxonomy terms and it feels like they should export. But I guess from that perspective it makes sense why they currently don't.)
I looked into the suggested modules, but ended up writing an update function to insert my taxonomy terms via Drupal API calls:
<?php
/**
* Helper function
*
* Assumes Drupal 7.14 or later (for second parameter of taxonomy_get_term_by_name).
*/
function my_feature_safe_add_terms($term_names, $vocabulary_name, $vocabulary_machine_name) {
// Make sure the vocabulary exists. This won't apply all desired options
// (description, etc.) but that's okay. Features will do that later.
// For now, we just need somewhere to stuff the terms.
$vocab = taxonomy_vocabulary_machine_name_load($vocabulary_machine_name);
if ($vocab === FALSE) {
$vocab = (object)array('name' => $vocabulary_name,
'machine_name' => $vocabulary_machine_name);
$vocab = taxonomy_vocabulary_machine_name_load($vocabulary_machine_name);
}
if (is_object($vocab) && property_exists($vocab, 'vid') && $vocab->vid > 0) {
// Load each term.
foreach ($term_names as $term_name) {
$term = taxonomy_get_term_by_name($term_name, $vocabulary_machine_name);
if (count($term) == 0) {
$term = (object)array('name' => $term_name,
'vid' => $vocab->vid);
taxonomy_term_save($term);
}
}
}
}
/**
* Insert your relevant comment here.
*/
function my_feature_update_7004() {
$term_names = array(
'Term One',
'Term Two',
);
my_feature_safe_add_terms($term_names, 'Vocab Name', 'vocab_machine_name');
// Do the same thing with additional vocabs.
}
?>
I don't propose this as an ideal "fits everyone's needs" solution. But it worked for my situation, so I thought I'd pass it along in case it helped anyone else.