I am using Features module and Strongarm to add variable to my feature.

The value of this variable is id of menu item.

  $strongarm = new stdClass();
  $strongarm->disabled = FALSE; /* Edit this to true to make a default strongarm disabled initially */
  $strongarm->api_version = 1;
  $strongarm->name = 'taxonomy_menu_vocab_parent_blog_category';
  $strongarm->value = '396';
  $export['taxonomy_menu_vocab_parent_category'] = $strongarm;

The problem is that on other site, where i enable my feature - that menu item has other id (not 396) - that is why this variable points to wrong menu item.

How i can solve this?

Can i transparently change this numeric id to something more site-independent (for example menu name plus menu item path, so instead 396 i will got "main-menu:blog") while variable is exported and imported?

Maybe i can write some preprocess function for this custom variable?

Comments

hefox’s picture

Project: Features » Strongarm
Version: 7.x-1.x-dev » 7.x-2.x-dev
Component: Ctools » Code
Status: Active » Fixed

hook_strongarm_alter; either override it there via looking up mlid or just define the variable there. Or have a seperate module with hook_strongarm in it defining the variable dynamically. (You don't actually have to use strongarm without features. It works fine by itself, thus the lack of dependency on features. )

DrupalDriven’s picture

hook_strogarm_alter seems not to work properly

i have tried

function taxonomy_menu_strongarm_alter(&$items) {
  if (isset($items['taxonomy_menu_vocab_parent_blog_category'])) {
    $items['taxonomy_menu_vocab_parent_blog_category']->value = 'my_cutom_value';
  }
}

But in downloaded feature file i still have old value of 'taxonomy_menu_vocab_parent_blog_category'.

I use the latest version of features and strongarm modules
What i am doing wrong?

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

skwashd’s picture

I think #2076543: Provide hooks for altering values on import and export will be a better way of solving your problem. You can even include the hook_strongarm_export_value_alter() and hook_strongarm_import_value_alter() in the .module file of your feature.