comparison documentation/ad_types.txt @ 0:d8a3998dac8e ad

ajout module ad
author pierre
date Fri, 20 Feb 2009 14:04:09 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:d8a3998dac8e
1 ---------
2 Overview:
3 ---------
4 This document is intended to help someone write a module for the ad api to
5 introduce a new ad type. The core ad module includes two ad type modules, one
6 for text ads and another for image ads. You can use the same api used by these
7 two ad type modules to create your own custom ad type module, for example you
8 may wish to write a module to ad support for flash ads. Some familiarity with
9 Drupal and PHP is required.
10
11 --------------------------
12 Naming your new ad module:
13 --------------------------
14 There are two ad types included with the core ad module, text ads and image
15 ads. Each ad type lives in its own module. Text ads are defined in the
16 ad_text module, and image ads are defined in the ad_image module. All
17 additional types of ads should be defined in modules following the same naming
18 scheme which is 'ad_' followed by the type of ad. For example, if you are
19 creating a module to add support for flash-based ads, you would call your
20 module ad_flash.
21
22 ------------------------------
23 Registering a new style of ad:
24 ------------------------------
25 Within the Drupal framework, ads are nodes. To create a new ad, a user
26 navigates to "create content >> ad", on which page they will be prompted
27 to select the type of the ad they wish to create. Your new ad type can
28 be added to this list by using the _adapi() hook and the 'type' operator.
29 For example, if creating a module for flash ads, you might add the following
30 function:
31
32 ad_flash_adapi($op, $ad = NULL) {
33 switch ($op) {
34 case 'type':
35 return array(
36 'flash' => array(
37 'name' => t('Flash ad'),
38 'module' => 'ad_flash',
39 'description' => t('A flash advertisement.'),
40 'help' => t('A flash advertisement.'),
41 ),
42 );
43 }
44 }
45
46 ------------------
47 Displaying your ad
48 ------------------
49 To display an ad, your ad type module needs to define the _display_ad() hook.
50 Be aware that when this function is called, many standard Drupal functions
51 are not available to you as the adtype.php script will only bootstrap to
52 DRUPAL_BOOTSTRAP_DATABASE.
53
54 You are passed in an object which contains the ad ID (aid) and the redirect
55 URL (ie 'ad/redirect/13'). Utilize this information to return the complete
56 advertisement. For example:
57
58 function ad_static_display_ad($ad) {
59 $return "<a href=\"$ad->redirect\">Static ad #$ad->aid</a>";
60 }
61
62 --------------------------------
63 Sharing your new ad_type module:
64 --------------------------------
65 The drupal.org CVS contributions repository requires that all included modules
66 be licesensed under the GPL. The ad module is dual licensed under both the
67 GPL and the BSD license, meeting this requirement. You can license your
68 new ad_style module under just the GPL, or under a dual license as long as
69 one of the licenses is the GPL.
70
71 If your module meets the above licensing requirements and you feel other Drupal
72 users could benefit from your work, contact the ad module maintainer to have
73 your module reviewed for inclusion.