source: sipes/modules_contrib/pathauto/API.txt @ cd414e9

stableversion-3.0
Last change on this file since cd414e9 was 177a560, checked in by José Gregorio Puentes <jpuentes@…>, 8 años ago

se agrego el directorio de modulos contribuidos de drupal

  • Propiedad mode establecida a 100755
File size: 6.9 KB
Línea 
1$Id: API.txt,v 1.5.2.3 2010/08/09 19:00:03 davereid Exp $
2
3This document explains how to provide "Pathauto integration" in a
4module. You need this if you would like to provide additional tokens
5or if your module has paths and you wish to have them automatically
6aliased.  The simplest integration is just to provide tokens so we
7cover that first.  More advanced integration requires an
8implementation of hook_pathauto to provide a settings form.
9
10It may be helpful to review some examples of integration from the
11pathauto_node.inc, pathauto_taxonomy.inc, and pathauto_user.inc files.
12
13
14==================
151 - Providing additional tokens
16==================
17
18If all you want is to enable tokens for your module you will simply
19need to implement two functions:
20
21  hook_token_values
22  hook_token_list
23
24See the token.module and it's API.txt for more information about this
25process.
26
27If the token is intended to generate a path expected to contain slashes,
28the token name must end in 'path', 'path-raw' or 'alias'. This indicates to
29Pathauto that the slashes should not be removed from the replacement value.
30
31When an object is created (whether it is a node or a user or a
32taxonomy term) the data that Pathauto hands to the token_values in the
33$object is in a specific format. This is the format that most people
34write code to handle. However, during edits and bulk updates the data
35may be in a totally different format. So, if you are writing a
36hook_token_values implementation to add special tokens, be sure to
37test creation, edit, and bulk update cases to make sure your code will
38handle it.
39
40==================
412 - Settings hook - To create aliases for your module
42==================
43You must implement hook_pathauto($op), where $op is always (at this
44time) 'settings'. Return an object (NOT an array) containing the
45following members, which will be used by pathauto to build a group
46of settings for your module and define the variables for saving your
47settings:
48
49module - The name of your module (e.g., 'node')
50groupheader - The translated label for the settings group (e.g.,
51  t('Node path settings')
52patterndescr - The translated label for the default pattern (e.g.,
53  t('Default path pattern (applies to all node types with blank patterns below)')
54patterndefault - A translated default pattern (e.g., t('[cat]/[title].html'))
55placeholders - An array whose keys consist of the translated placeholders
56  which will appear in patterns (e.g., t('[title]')) and values are
57  the translated description of the placeholders (e.g.,
58  t('The title of the node, with spaces and punctuation.')
59patternitems - For modules which need to express multiple patterns
60  (for example, the node module supports a separate pattern for each
61  node type), an array whose keys consist of identifiers for each
62  pattern (e.g., the node type name) and values consist of the
63  translated label for the pattern
64supportsfeeds - Modules which support RSS feeds should set this to the
65  string that's appended to a path for its feed (usually 'feed') , so
66  when administrators enable "Create feed aliases" an alias for this
67  content type's feed will be generated in addition to the base alias.
68bulkname - For modules which support a bulk update operation, the
69  translated label for the action (e.g., t('Bulk update node paths'))
70bulkdescr - For modules which support a bulk update operation, a
71  translated, more thorough description of what the operation will do
72  (e.g., t('Generate aliases for all existing nodes which do not already have aliases.'))
73
74
75==================
762 - $alias = pathauto_create_alias($module, $op, $placeholders, $src, $type=NULL)
77==================
78
79At the appropriate time (usually when a new item is being created for
80which a generated alias is desired), call pathauto_create_alias() to
81generate and create the alias.  See the user, taxonomy, and nodeapi hook
82implementations in pathauto.module for examples.
83
84$module - The name of your module (e.g., 'node')
85$op - Operation being performed on the item ('insert', 'update', or
86  'bulkupdate')
87$placeholders - An array whose keys consist of the translated placeholders
88  which appear in patterns and values are the "clean" values to be
89  substituted into the pattern. Call pathauto_cleanstring() on any
90  values which you do not know to be purely alphanumeric, to substitute
91  any non-alphanumerics with the user's designated separator. Note that
92  if the pattern has multiple slash-separated components (e.g., [catpath]),
93  pathauto_cleanstring() should be called for each component, not the
94  complete string.
95  Example: $placeholders[t('[title]')] = pathauto_cleanstring($node->title);
96$src - The "real" URI of the content to be aliased (e.g., "node/$node->nid")
97$type - For modules which provided patternitems in hook_autopath(),
98  the relevant identifier for the specific item to be aliased (e.g.,
99  $node->type)
100
101pathauto_create_alias() returns the alias that was created.
102
103
104==================
1053 - Bulk update function
106==================
107
108If a module supports bulk updating of aliases, it must provide a
109function of this form, to be called by pathauto when the corresponding
110checkbox is selected and the settings page submitted:
111
112function <module>_pathauto_bulkupdate()
113
114The function should iterate over the content items controlled by the
115module, calling pathauto_create_alias() for each one. It is
116recommended that the function report on its success (e.g., with a
117count of created aliases) via drupal_set_message().
118
119
120==================
1214 - Bulk delete hook_path_alias_types()
122==================
123
124For modules that create new types of pages that can be aliased with pathauto, a
125hook implementation is needed to allow the user to delete them all at once.
126
127function hook_path_alias_types()
128
129This hook returns an array whose keys match the beginning of the source paths
130(e.g.: "node/", "user/", etc.) and whose values describe the type of page (e.g.:
131"content", "users"). Like all displayed strings, these descriptionsshould be
132localized with t(). Use % to match interior pieces of a path; "user/%/track". This
133is a database wildcard, so be careful.
134
135
136==================
137Modules that extend node and/or taxonomy
138==================
139
140NOTE: this is basically not true any more.  If you feel you need this file an issue.
141
142Many contributed Drupal modules extend the core node and taxonomy
143modules. To extend pathauto patterns to support their extensions, they
144may implement the pathauto_node and pathauto_taxonomy hooks.
145
146To do so, implement the function <modulename>_pathauto_node (or _taxonomy),
147accepting the arguments $op and $node (or $term). Two operations are
148supported:
149
150$op = 'placeholders' - return an array keyed on placeholder strings
151(e.g., t('[eventyyyy]')) valued with descriptions (e.g. t('The year the
152event starts.')).
153$op = 'values' - return an array keyed on placeholder strings, valued
154with the "clean" actual value for the passed node or category (e.g.,
155pathauto_cleanstring(date('M', $eventstart)));
156
157See contrib/pathauto_node_event.inc for an example of extending node
158patterns.
Nota: Vea TracBrowser para ayuda de uso del navegador del repositorio.