Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
When I migrate code and settings from staging to production, I need a way to migrate themekey properties/rules. Is there a function that I can use to do this? I would put my code in a hook_update function, or I would put it in a standalone script to be executed via 'drush php-script'.
I don't see an import/export function, so calling a function seems like the only route.
Thanks,
Cliff
Comments
Comment #1
mkalkbrennerYou can use ThemeKey's (experimental) support of https://drupal.org/project/features
Comment #2
meecect CreditAttribution: meecect commentedyes, I was just browsing the code and saw the feature support right after posting. However, I'm loath to install features just to get this. It would require a complete change in our development workflow, and more modules to install and test. Isn't there any function like themekey_rule_save(&$rule_array) or something?
I was looking in the database, and it seems like the data structure is quite simple:
nid property operator value weight theme enabled wildcards parent module
1 taxonomy:tid_and_childs = 87 1 pokemon_xy 1 a:0:{} 0 themekey
I'm tempted to just use db_query and insert my row, ut I'd like to use a function that might give other modules an opportunity to fire their hooks. All of my entries will be basically the same as the above sample, but with just different values and theme contents.
Thanks for the quick response,
Cliff
Comment #3
meecect CreditAttribution: meecect commentedmaybe themekey_rule_set() ?
Comment #4
mkalkbrennerYes, the API you're looking for is located in themekey_build.inc.
https://drupal.org/project/mobile_tools 7.x-3.x is using it.
Comment #5
mkalkbrennerBTW the features export stuff creates nothing else than php code that could be evaluated to import ThemeKey rules.
Maybe you can simply trigger that code manually without features ;-)
This code uses ThemeKey's API.
Comment #6
meecect CreditAttribution: meecect commentedthanks, themekey_rule_set works fine.
Comment #7
mkalkbrennerComment #8
couloir007 CreditAttribution: couloir007 commentedI want to create and enable a rule with drush, the code I use below works as long as I don't set the enabled variable.
If I don't set enabled, it creates it disabled, if I do I get:
Drush command terminated abnormally due to an unrecoverable error. [error]
Error: Call to undefined function themekey_rule_set() in...
Any insight would be great.
Thank you.
Comment #9
nmillin CreditAttribution: nmillin commented@couloir007's code works great with hook_update_N(), but I needed to update
to
Just adding a note in case someone else tries to do this. Thanks!