The Rules module comes with a nice Import/Export feature which makes it easy to move complicated sets of rules from one environment to another without a bunch of unnecessary re-configuration. The simplest way is to simply copy the code out of the 'export' page ( an array ), and paste it into the 'Import' page on the target installation.
An even cooler way to move rules and be sure they're available to custom modules that depend on them is to include hook_rules_defaults() in your module code.
An example would look like this:
function hook_rules_defaults() {
$rules = // paste the exported rules array here and add a ';' at the end of the array
return $rules;
}
When the module is installed, so are the rules outlined in the array.
Snippets of code and tricks that would otherwise be forgotten. Useful for me, hopefully for you too.
Wednesday, October 24, 2012
Friday, October 19, 2012
Drupal - Theming Views
http://pedroposada.com/blog/embed-views-2-nodes.html
methods available to a $view object:
http://drupalcontrib.org/api/drupal/contributions%21views%21includes%21view.inc/class/view/6
Registering template files in hook_theme():
'views_view_table__map_requests__panel_pane_2' => array(
'template' => 'views-view-table--map-requests--panel-pane-2',
'path' => drupal_get_path("module","maprequest") . '/themes',
),
Pass variables through to the template using:
function maprequest_theme_registry_alter (&$theme_registry) {
{
$tpl = $theme_registry['views_view_table'];
$theme_registry['views_view_table__map_requests__panel_pane_2']['arguments'] = $tpl['arguments'];
$theme_registry['views_view_table__map_requests__panel_pane_2']['preprocess functions'] = $tpl['preprocess functions'];
}
}
methods available to a $view object:
http://drupalcontrib.org/api/drupal/contributions%21views%21includes%21view.inc/class/view/6
Registering template files in hook_theme():
'views_view_table__map_requests__panel_pane_2' => array(
'template' => 'views-view-table--map-requests--panel-pane-2',
'path' => drupal_get_path("module","maprequest") . '/themes',
),
Pass variables through to the template using:
function maprequest_theme_registry_alter (&$theme_registry) {
{
$tpl = $theme_registry['views_view_table'];
$theme_registry['views_view_table__map_requests__panel_pane_2']['arguments'] = $tpl['arguments'];
$theme_registry['views_view_table__map_requests__panel_pane_2']['preprocess functions'] = $tpl['preprocess functions'];
}
}
Friday, October 5, 2012
Nexus 7 - Setting up USB debugging
I recently bought a ASUS Nexus 7 tablet and I'm very pleased with it. I'm particularly happy that it came with Android 4.1 (Jellybean) because I'm interested in using it as a development device for web and apps.
I was excited to learn that by plugging my tablet into my computer I can get full access to Chrome developer tools. The setup was just a little more involved than I had planned. It's hard to say if everyone will encounter these same hurdles, but the following sequence of events got mine working!
Setup Nexus 7 for Chrome USB debugging:
On Nexus 7:
- In Chrome settings, enable USB debugging
- In Device Settings -> Developer Options -> enable USB debugging
- Device Settings -> Storage -> Settings -> USB computer connection -> enable MTP
On PC:
- Plug in device
- Install Java JDK from oracle
- (optional) Download and install Eclipse Classic 4.2.1 or newer
- Install Android SDK
- Launch Android SDK Manager ( start as administrator! )
- Install Adroid 4.1, all tools, and the google usb driver
Download drivers from ASUS site:
- http://support.asus.com/Download.aspx?SLanguage=en&m=Nexus+7&p=20&s=16
- select the 'Global' download option ( middle of three )
In Windows device manager locate the Nexus 7 - generally under 'Other devices'
- 'Update Driver Software' -> browse to local copy of downloaded drivers & install
- Device should now be listed as an android phone
Check Device Connectivity:
- Open command prompt and change directory to C:\Program Files (x86)\Android\android-sdk\platform-tools ( or the location of adb.exe )
- Execute command: 'adb devices' - the device should be listed. if not you have failed somewhere
Set up Chrome debugging:
- Execute: 'adb forward tcp:9222 localabstract:chrome_devtools_remote'
- Go to Chrome, navigate to localhost:9222 -> tabs on nexus chrome should be visible for debugging
And hopefully that will get you there...
Update: If you're still having trouble, check that the 'USB Computer Connection' type is set to PTP. This setting can be located in Settings -> Storage -> (menu) USB Computer Connection.
I was excited to learn that by plugging my tablet into my computer I can get full access to Chrome developer tools. The setup was just a little more involved than I had planned. It's hard to say if everyone will encounter these same hurdles, but the following sequence of events got mine working!
Setup Nexus 7 for Chrome USB debugging:
On Nexus 7:
- In Chrome settings, enable USB debugging
- In Device Settings -> Developer Options -> enable USB debugging
- Device Settings -> Storage -> Settings -> USB computer connection -> enable MTP
On PC:
- Plug in device
- Install Java JDK from oracle
- (optional) Download and install Eclipse Classic 4.2.1 or newer
- Install Android SDK
- Launch Android SDK Manager ( start as administrator! )
- Install Adroid 4.1, all tools, and the google usb driver
Download drivers from ASUS site:
- http://support.asus.com/Download.aspx?SLanguage=en&m=Nexus+7&p=20&s=16
- select the 'Global' download option ( middle of three )
In Windows device manager locate the Nexus 7 - generally under 'Other devices'
- 'Update Driver Software' -> browse to local copy of downloaded drivers & install
- Device should now be listed as an android phone
Check Device Connectivity:
- Open command prompt and change directory to C:\Program Files (x86)\Android\android-sdk\platform-tools ( or the location of adb.exe )
- Execute command: 'adb devices' - the device should be listed. if not you have failed somewhere
Set up Chrome debugging:
- Execute: 'adb forward tcp:9222 localabstract:chrome_devtools_remote'
- Go to Chrome, navigate to localhost:9222 -> tabs on nexus chrome should be visible for debugging
And hopefully that will get you there...
Update: If you're still having trouble, check that the 'USB Computer Connection' type is set to PTP. This setting can be located in Settings -> Storage -> (menu) USB Computer Connection.
Subscribe to:
Posts (Atom)