source: sipes/modules_contrib/pathauto/API.txt @ 49072ea

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

se actualizo el modulo

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