Hi - I want to set a variable in an array to true in my install script so that each site I spin up already has the variable enabled. But, I can't seem to figure out how exactly to set the variable since it is in an array.
The variable of the array is admin_menu_components. The variable within the array that I would like to set to true is admin_menu.account.
Here is what I've tried using drush:
php -r "print json_encode(array('drupal', 'admin_menu_components'));" | drush vset --format=json admin_menu.account -
php -r "print json_encode(array('drupal', 'admin_menu.account'));" | drush vset --format=json admin_menu.account -
php -r "print json_encode(array('admin_menu.account'));" | drush vset --format=json admin_menu.account -
php -r "print json_encode(array('admin_menu_components', 'admin_menu.account'));" | drush vset --format=json admin_menu.account -
I also just tried to vset the admin_menu_components to 1 or TRUE and it broke my site. It's just a local version, so that's not a big deal...but that didn't work either.
Drush keeps telling me that it is setting the value to 1 and that it was a success, but the variable is not actually getting changed on the site.
What I'm trying to turn on by default is located at admin/config/administration/admin_menu - the Account Links option.
Thanks for any help!
Comments
php -r "print json_encode
php -r "print json_encode(array('drupal', 'admin_menu_components'));" | drush vset --format=json admin_menu.account -
This will write the serialized array:
array('drupal', 'admin_menu_components'))
into the variable with the name "admin_menu.account" - which doesn't exist afaik.
I think you flipped around things a bit in your statement. Compare with: http://drushcommands.com/drush-7x/variable/variable-set
I like cookies!
I did compare
I did compare...obviously I used that particular command and tried to get it to work to my advantage.
I also tried it in numerous ways, as I mentioned above. I guess I'm not following your instructions on what you think I did wrong. Maybe if you could provide a more detailed explanation.
drush eval
I recommend using drush eval for this:
drush ev 'variable_set("your_variable", array("key" => "value"))'
This method worked great for
This method worked great for me to set array values, thanks!