CiviCRM Community Forums (archive)

*

News:

Have a question about CiviCRM?
Get it answered quickly at the new
CiviCRM Stack Exchange Q+A site

This forum was archived on 25 November 2017. Learn more.
How to get involved.
What to do if you think you've found a bug.



  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Please advise: Promotion of Civi-enabled webforms
Pages: [1]

Author Topic: Please advise: Promotion of Civi-enabled webforms  (Read 1829 times)

CRAK

  • I’m new here
  • *
  • Posts: 9
  • Karma: 0
  • CiviCRM version: 4.4.x
  • CMS version: Drupal 7.26
  • MySQL version: 5.6.12
  • PHP version: 5.4.16
Please advise: Promotion of Civi-enabled webforms
March 10, 2014, 07:58:28 am
In our DEV environment, people have built a handful of webforms (Drupal 7.x): drupal fields and both standard and custom civi fields for contacts, cases and activities.
The challenge is now to wrap the webforms definitions in code, to promote it to TEST etc.

We're running Civi 4.4, the Webform 4.x branch and the 4.x webform integration branch.
I've noticed that "Webform Features" is not (yet) compatibel with the Webform 4.x branch, so I've chosen Node Export for a first attempt. Unfortunately, important deatails (e.g. Case related fields) get lost in the process (simple import using GUI).

I'm sure I'm not the only one in this struggle. Does anyone have any recommendations to archieve this please?

Coleman Watts

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 2346
  • Karma: 183
  • CiviCRM version: The Bleeding Edge
  • CMS version: Various
Re: Please advise: Promotion of Civi-enabled webforms
March 10, 2014, 08:29:10 am
https://drupal.org/node/2111713
I would welcome any patches or ideas about how to get them working together.
Try asking your question on the new CiviCRM help site.

petednz

  • Forum Godess / God
  • I’m (like) Lobo ;)
  • *****
  • Posts: 4899
  • Karma: 193
    • Fuzion
  • CiviCRM version: 3.x - 4.x
  • CMS version: Drupal 6 and 7
Re: Please advise: Promotion of Civi-enabled webforms
March 10, 2014, 09:35:38 pm
i use Node Export in D7 and found that quite a lot of the civi stuff was carried over and that i needed to go in to the civi tab - enable civicrm processing - set the right number of civi contacts etc - can't recall if i had to reselect the fields - but having done that it all fired fine - so may be worth having a further go.
Sign up to StackExchange and get free expert advice: https://civicrm.org/blogs/colemanw/get-exclusive-access-free-expert-help

pete davis : www.fuzion.co.nz : connect + campaign + communicate

CRAK

  • I’m new here
  • *
  • Posts: 9
  • Karma: 0
  • CiviCRM version: 4.4.x
  • CMS version: Drupal 7.26
  • MySQL version: 5.6.12
  • PHP version: 5.4.16
Re: Please advise: Promotion of Civi-enabled webforms
March 13, 2014, 02:34:14 pm
Quote from: petednz on March 10, 2014, 09:35:38 pm
i use Node Export in D7 and found that quite a lot of the civi stuff was carried over and that i needed to go in to the civi tab - enable civicrm processing - set the right number of civi contacts etc - can't recall if i had to reselect the fields - but having done that it all fired fine - so may be worth having a further go.
Thanks for your response Petednz. I've noticed that too. Sadly it seems that some details are just not provided in the export file yet, so I'm looking for other options and success stories. After all: every checkbox, name references or other setting that requires additional attention will call upon Murphy's Law.

CRAK

  • I’m new here
  • *
  • Posts: 9
  • Karma: 0
  • CiviCRM version: 4.4.x
  • CMS version: Drupal 7.26
  • MySQL version: 5.6.12
  • PHP version: 5.4.16
Re: Please advise: Promotion of Civi-enabled webforms
March 13, 2014, 02:53:58 pm
Quote from: Coleman Watts on March 10, 2014, 08:29:10 am
https://drupal.org/node/2111713
I would welcome any patches or ideas about how to get them working together.
Hi Coleman, I've come across that page earlier. I need to fix a few other things first and take a closer look on the Webform Share module as an alternative, but I just might get back to you on that.
Meanwhile (consider that I'm too "newbie" to figure out everything yet): if I add exported arrays to my own code, how would I get them imported easily?

Coleman Watts

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 2346
  • Karma: 183
  • CiviCRM version: The Bleeding Edge
  • CMS version: Various
Re: Please advise: Promotion of Civi-enabled webforms
March 13, 2014, 04:16:05 pm
Well assuming you can get the webform node exported, the only extra thing needed by webform_civicrm is the row from webform_civicrm_forms sql table. Only catch with exporting directly from sql is you'll need to update the node id to match the new node on your other site.
Try asking your question on the new CiviCRM help site.

CRAK

  • I’m new here
  • *
  • Posts: 9
  • Karma: 0
  • CiviCRM version: 4.4.x
  • CMS version: Drupal 7.26
  • MySQL version: 5.6.12
  • PHP version: 5.4.16
Re: Please advise: Promotion of Civi-enabled webforms
April 18, 2014, 09:05:48 am
Quote from: Coleman Watts on March 13, 2014, 04:16:05 pm
Well assuming you can get the webform node exported, the only extra thing needed by webform_civicrm is the row from webform_civicrm_forms sql table. Only catch with exporting directly from sql is you'll need to update the node id to match the new node on your other site.
You're absolutely right:
I exported a webform using node export, and exported the data from webform_civicrm_forms using phpMyAdmin. I edited the obtained sql file and removed all records that did not relate to the exported webforms nid.
Then I went through all webform-tables and removed every record containing the nid of the exported webform.
After clearing all of Drupals caches, I started by importing the webform (node export: import). Next, I executed the edited sql to restore the webform_civicrm_forms record and fixed its nid (could have done that in the sql file of course).
Works perfectly! I can even learn to live with the small amount of extra hassle.

If it helps anyone to fix the node export module: the export itself appears ok. node_export.module, function node_export, line 343 clearly returns $node object containing both a webform and a webform_civicrm arrays for civi enabled webforms (checkbox named "nid" containing the actual nid value). Webforms that do not have civicrm enabled only contain the webform array. The actual exports (screen) show the exact same difference, including the nid in the webform_civicrm array.
I conclude that its only the import that fails somewhere. Haven't looked into that yet.

CRAK

  • I’m new here
  • *
  • Posts: 9
  • Karma: 0
  • CiviCRM version: 4.4.x
  • CMS version: Drupal 7.26
  • MySQL version: 5.6.12
  • PHP version: 5.4.16
Re: Please advise: Promotion of Civi-enabled webforms
April 18, 2014, 09:12:13 am
Forgot one word:
Thanks!  ;D

Coleman Watts

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 2346
  • Karma: 183
  • CiviCRM version: The Bleeding Edge
  • CMS version: Various
Re: Please advise: Promotion of Civi-enabled webforms
April 18, 2014, 11:41:34 am
Hey CRAK, since you're in the mood for testing things out how about trying this patch. I think it fixes compatibility with node_export module.
Code: [Select]
diff --git a/webform_civicrm.module b/webform_civicrm.module
index 958bb42..aec6e55 100644
--- a/webform_civicrm.module
+++ b/webform_civicrm.module
@@ -138,6 +138,21 @@ function webform_civicrm_node_insert($node) {
 }
 
 /**
+ * Implements hook_node_export_after_import_alter().
+ * For compatibility with node_export module
+ *
+ * @param array $nodes
+ */
+function webform_civicrm_node_export_after_import_alter(&$nodes) {
+  foreach ($nodes as $nid => $node) {
+    if (isset($node->webform_civicrm) && $node->webform_civicrm['nid'] != $nid) {
+      $node->webform_civicrm['nid'] = $nid;
+      drupal_write_record('webform_civicrm_forms', $node->webform_civicrm);
+    }
+  }
+}
+
+/**
  * Implements hook_node_delete().
  *
  * @param object $node
Try asking your question on the new CiviCRM help site.

CRAK

  • I’m new here
  • *
  • Posts: 9
  • Karma: 0
  • CiviCRM version: 4.4.x
  • CMS version: Drupal 7.26
  • MySQL version: 5.6.12
  • PHP version: 5.4.16
Re: Please advise: Promotion of Civi-enabled webforms
April 18, 2014, 02:02:11 pm
Quote from: Coleman Watts on April 18, 2014, 11:41:34 am
Hey CRAK, since you're in the mood for testing things out how about trying this patch. I think it fixes compatibility with node_export module.
Code: [Select]
diff --git a/webform_civicrm.module b/webform_civicrm.module
index 958bb42..aec6e55 100644
--- a/webform_civicrm.module
+++ b/webform_civicrm.module
@@ -138,6 +138,21 @@ function webform_civicrm_node_insert($node) {
 }
 
 /**
+ * Implements hook_node_export_after_import_alter().
+ * For compatibility with node_export module
+ *
+ * @param array $nodes
+ */
+function webform_civicrm_node_export_after_import_alter(&$nodes) {
+  foreach ($nodes as $nid => $node) {
+    if (isset($node->webform_civicrm) && $node->webform_civicrm['nid'] != $nid) {
+      $node->webform_civicrm['nid'] = $nid;
+      drupal_write_record('webform_civicrm_forms', $node->webform_civicrm);
+    }
+  }
+}
+
+/**
  * Implements hook_node_delete().
  *
  * @param object $node

That's exactly what was missing! Is does the job perfectly!
Thanks again!


Coleman Watts

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 2346
  • Karma: 183
  • CiviCRM version: The Bleeding Edge
  • CMS version: Various
Re: Please advise: Promotion of Civi-enabled webforms
April 18, 2014, 02:10:54 pm
OK committed to 3.x and 4.x branches and marked issue as fixed. Thanks for testing.
Try asking your question on the new CiviCRM help site.

Coleman Watts

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 2346
  • Karma: 183
  • CiviCRM version: The Bleeding Edge
  • CMS version: Various
Re: Please advise: Promotion of Civi-enabled webforms
April 18, 2014, 02:28:51 pm
Update: I found a better solution that should work for all node clone/copy operations, not just node_export. See updates to https://drupal.org/node/2111713
Try asking your question on the new CiviCRM help site.

CRAK

  • I’m new here
  • *
  • Posts: 9
  • Karma: 0
  • CiviCRM version: 4.4.x
  • CMS version: Drupal 7.26
  • MySQL version: 5.6.12
  • PHP version: 5.4.16
Re: Please advise: Promotion of Civi-enabled webforms
April 19, 2014, 02:24:43 pm
Quote from: Coleman Watts on April 18, 2014, 02:28:51 pm
Update: I found a better solution that should work for all node clone/copy operations, not just node_export. See updates to https://drupal.org/node/2111713
I tried the more generalized update for the 4.x branch as well: looks ok. Will give it some more thorough testing with conditionals, groups and page separators next week in office.
But what did you mean with the phrase "more generalized solution to cloning/copying node"? That it is supposed to support other modules for importing/exporting besides "node export"?
Just to let you know (if that's what you expected it to do): I've tried Webform Share 7.x 1.2 for the occasion, but that one lets me down.

Coleman Watts

  • Administrator
  • I’m (like) Lobo ;)
  • *****
  • Posts: 2346
  • Karma: 183
  • CiviCRM version: The Bleeding Edge
  • CMS version: Various
Re: Please advise: Promotion of Civi-enabled webforms
April 19, 2014, 05:19:09 pm
Code: [Select]
That it is supposed to support other modules for importing/exporting besides "node export"?Yes that was the idea. It refactors the two hacks for node_clone and node_export into a more general solution that "should" work anytime a webform is inserted that contains civicrm data.
Try asking your question on the new CiviCRM help site.

Pages: [1]
  • CiviCRM Community Forums (archive) »
  • Old sections (read-only, deprecated) »
  • Developer Discussion (Moderator: Donald Lobo) »
  • Please advise: Promotion of Civi-enabled webforms

This forum was archived on 2017-11-26.