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

rajiv.singh’s picture

hemant_gautam’s picture

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.

rgchi’s picture

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.

bpirkle’s picture

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:


/**
 * 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.

stefgosselin’s picture

This has been up a few years, still relevant in 2016. Very cool way to add terms, thanks for the addition to my 400+ webdev snippets of all sorts, and the solution to a painful content creation problem I had very short time-frame to solve.

Whoever wrote this above, thanks for the cue.

shashwat purav’s picture

Firstly you’ll need to install the UUID Features (https://drupal.org/project/uuid_features) , Features (https://drupal.org/project/features) and UUID (https://drupal.org/project/uuid) modules.

Once all those modules are enabled, go to example.com/admin/config/content/uuid_features (or on your administration menu go to Administration –> Content Authoring –> UUID Features Integration, and under “Exportable Taxonomy term bundles” check the boxes for the relevant taxonomy terms.

Go to your features export page at example.com/admin/structure/features/ (or on your administration menu go to Administration –> Structure –> Features), create/recreate the feature and you’ll see “Taxonomy Terms” listed.

Thank You,
Shashwat Purav

gauravjeet’s picture

thanks.. it worked :)

- GJ

websomhelst’s picture

Hi

I followed your suggestion above to export a taxonomy term and a view in a feature.

When I installed and activated the created feature on another site afterwards, the taxonomy term was created and so was the view, but the view did not recognize the term. If I edit the view and choose the term, everything works fine.

Any ideas as to why this happens?

akalata’s picture

I'm 99% sure its because the term on your origin site does not have the same term ID (tid) as on the later site. The term name was likely carried over, but it is almost guaranteed to have a different tid since those are sequential, rather than specified like machine names. The view config UI pulls in the term name, but it really saves the tid value into its config.

rodrigo panchiniak fernandes’s picture

If you use vs. 7.x-1.0-rc1 and possibly later path updated to /admin/structure/features/uuid_features