Closed (fixed)
Project:
ThemeKey
Version:
7.x-3.0
Component:
Code / API
Priority:
Normal
Category:
Support request
Assigned:
Unassigned
Reporter:
Created:
28 Feb 2014 at 16:42 UTC
Updated:
13 Feb 2019 at 15:56 UTC
Jump to comment: Most recent
Comments
Comment #1
mkalkbrennerYou can use ThemeKey's (experimental) support of https://drupal.org/project/features
Comment #2
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 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 commentedthanks, themekey_rule_set works fine.
Comment #7
mkalkbrennerComment #8
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 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!