Commit | Line | Data |
---|---|---|
7f254ad8 AE |
1 | {literal} |
2 | <script> | |
3 | if (FB != undefined) { // reprocess the XFBML tags if called in ajax (otherwise, that's done by the init) | |
4 | FB.XFBML.parse(document.getElementById('socialnetwork')); | |
5 | ||
6 | } | |
7 | </script> | |
8 | {/literal} | |
9 | ||
10 | {* | |
11 | You might have a specific page that displays more information that the form. | |
12 | ||
13 | This is an example (taken from http://www.etownhall.eu) that assumes that there is a Drupal node | |
14 | that contains a cck field 'petitionid'. | |
15 | This node is going to be used for the social networks promotion instead of the form. | |
16 | ||
17 | This is an example of how to fetch content from a Drupal node (that contains a cck field 'petitionid') | |
18 | You will want to customise it based on your configuration. | |
19 | ||
20 | How to install ? | |
21 | Create a custom template folder and copy this file into CRM/Campaign/Page/Petition/SocialNetwork.tpl | |
22 | This assumes you are on Drupal, have installed the fb module (drupal.org/project/fb), | |
23 | and in general, is very unlikely to work directly. Please consider this as an example, | |
24 | and modify to fit your specific configuration. | |
25 | *} | |
26 | ||
27 | ||
28 | {php} | |
29 | /** | |
30 | * Function to get Petition Drupal Node Path/Alias | |
31 | * | |
32 | * @param int $surveyId | |
33 | * @static | |
34 | */ | |
35 | function &getPetitionDrupalNodeData( $surveyId ) { | |
36 | /* | |
37 | Other approach: using the view | |
38 | $view=views_get_view("node_petition"); //replace with the name of your view | |
39 | $view->set_arguments(array($surveyId)); | |
40 | $view->build('default'); //use "default" if you want to retrieve the default display of your view, if not, the name of the specific display | |
41 | $view->execute(); | |
42 | foreach($view->result as $result) { //$result | |
43 | // Do something with $result here. Each result is an object, so for example you can access the nid using $result->nid | |
44 | } | |
45 | */ | |
46 | $config = CRM_Core_Config::singleton( ); | |
47 | $surveyId = (int)$surveyId;// sql injection protection | |
48 | // if Drupal node uses cck integer field petitionid | |
49 | // there will be a 'content_field_petitionid' table in the Drupal database | |
50 | // that stores field_petitionid_value against nid (node id) | |
51 | ||
52 | $result = db_query("SELECT * FROM content_type_petition WHERE field_petitionid_value = " . $surveyId); | |
53 | ||
54 | global $base_url; | |
55 | $petition = array(); | |
56 | $data = db_fetch_array ($result); | |
57 | ||
58 | if (!$data) { | |
59 | return null; | |
60 | } | |
61 | ||
62 | $petition_node = node_load ($data['nid']); | |
63 | $petition_node->url = $base_url . "/" . drupal_get_path_alias("node/".$data['nid']); | |
64 | $petition_node->title = node_page_title(node_load($data['nid'])); | |
65 | ||
66 | return array_merge ((array)$petition_node,(array)$data); | |
67 | } | |
68 | ||
69 | global $base_url; | |
70 | $this->assign('base_url', $base_url); | |
71 | $email = $this->get_template_vars('email'); | |
72 | $noscript = $this->get_template_vars('noscript'); | |
73 | $petition_id = $this->get_template_vars('petition_id'); | |
74 | $node = getPetitionDrupalNodeData($petition_id); | |
75 | $this->assign_by_ref('node', $node); | |
76 | ||
77 | {/php} | |
78 | ||
79 | {if $node.nid} | |
80 | {* print additional thank you email text from Drupal petition node if there is a cck text field 'email' *} | |
81 | {if $email} | |
82 | <br />{$node.field_email.0.value} | |
83 | {/if} | |
84 | ||
85 | <!-- Social Networking --> | |
86 | <h2>Help spread the word about "{$node.title}"</h2> | |
87 | Please help us and let your friends, colleagues and followers know about our campaign. | |
88 | <h3>Do you use Facebook or Twitter ?</h3> | |
89 | ||
90 | <div class="socialnetwork"> | |
91 | {if $noscript} | |
92 | <p>Share it on Facebook or tweet it on Twitter.</p> | |
93 | <a href="http://www.facebook.com/sharer.php?u={$node.url}&t={$node.title}"> | |
94 | <img src="{$base_url}/sites/all/modules/civicrm/i/fbshare.png" width="70px" height="28px" title="Facebook Share Button"> | |
95 | </a> | |
96 | | |
97 | | |
98 | | |
99 | | |
100 | <a href="http://twitter.com/share?url={$node.url}&text=Sign this, I did: {$node.title}"> | |
101 | <img src="{$base_url}/sites/all/modules/civicrm/i/tweet.png" width="55px" height="20px" title="Tweet Button""> | |
102 | </a> | |
103 | {else} | |
104 | <p>Like it on Facebook or tweet it on Twitter.</p> | |
105 | <fb:like href="{$node.url}"></fb:like> | |
106 | <script src="http://platform.twitter.com/widgets.js" type="text/javascript"></script> | |
107 | <a href="http://twitter.com/share?url={$node.url}&text=Sign this, I did: {$node.title}" class="twitter-share-button" title="tweet about this petition">Tweet</a> | |
108 | {/if} | |
109 | </div> | |
110 | <h3>Do you have a website for your organisation or yourself?</h3> | |
111 | You can write a story about it - don't forget to add the link to <a href="{$node.url}">{$node.url}.</a> | |
112 | {/if} |