/[drupal]/contributions/modules/og_settings/README.txt
ViewVC logotype

Contents of /contributions/modules/og_settings/README.txt

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.2 - (show annotations) (download)
Thu Jun 5 17:49:01 2008 UTC (17 months, 2 weeks ago) by ferdi
Branch: MAIN
CVS Tags: HEAD
Changes since 1.1: +65 -11 lines
File MIME type: text/plain
how one can use og_settings api
1 // $Id$
2
3 NOTE
4 ----
5
6 This is an api module for developers. It doesnt do much on its own. Please install if required by other modules.
7
8 DESCRIPTION
9 -----------
10
11 og_settings module helps developers to use a standard api and database schema for getting/setting persistent variables
12 for each organic group. The api (and implementation) is similar to drupal core api functions for storing/getting/setting
13 site-wide persistent variables (variable_get(), variables_set(), variable_del()):
14
15 og_settings_variable_set($gid, $name, $value) : Sets a persistent variable for group "$gid"
16
17 og_settings_variable_get($gid, $name, $default) : Returns a persistent variable for the group "$gid"
18
19 og_settings_variable_del($gid, $name) : Delete a persistent variable "$name" for organic group "$gid"
20
21 og_settings_variable_del_all($gid) : Deletes all persistent variables for organic group "$gid"
22
23
24 This module also simplify the process of creating forms used by users (typically group administrators) to set/change
25 the value of persistent variables for their group (similar to "system_setting_form()" offered by drupal core):
26
27 og_settings_form($form, $gid) : Add default buttons to an og settings form.
28
29 NOTE
30 ----
31
32 Variable values are serialized and cached, so you are free to through anything in there.
33
34
35 EXAMPLE
36 -------
37
38 There is a mini module (og_info) included in this package as an example of how a module would use og_settings API.
39
40 og_info allows group administrators to provide some information about their group (group name, mail, slogan, footer etc).
41 It's similar to how Drupal core (system module) allows site administrators to set some information about the web
42 site (see admin/settings/site-information)
43
44 Developers/themers can use this info in different ways. Here is what I do in one my sites:
45
46 - Add the following code in the "template.php" file:
47
48 /**
49 * Override or insert PHPTemplate variables into the templates.
50 */
51 function _phptemplate_variables($hook, $vars) {
52
53 switch($hook){
54 case 'node':
55 // you maybe have some code here
56 return $vars;
57 break;
58
59 case 'page':
60
61 $gnode = og_get_group_context();
62 if ($gnode -> nid){
63 $vars['site_name'] = og_settings_variable_get($gnode -> nid, 'og_info_name', '');
64 $vars['site_mail'] = og_settings_variable_get($gnode -> nid, 'og_info_mail', '');
65 $vars['site_slogan'] = og_settings_variable_get($gnode -> nid, 'og_info_slogan', '');
66 $vars['site_mission'] = og_settings_variable_get($gnode -> nid, 'og_info_mision', '');
67 $vars['site_footer'] = og_settings_variable_get($gnode -> nid, 'og_info_footer', '');
68 return $vars;
69 break;
70
71 case 'comment':
72 // maybe some more code
73 return $vars;
74 break;
75 }
76
77 return array();
78 }
79
80
81 - You usually dont have to change anything in page.tpl.php:
82
83 e.g. print $site_name will print "og_info_name" if you are looking at a particluar group, or the Drupal "site_name"
84 if in other part of your site.
85
86
87
88

  ViewVC Help
Powered by ViewVC 1.1.2