source: sipes/modules_contrib/views/help/api-handler-area.html @ 65dadeb

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

se agregaron los archivos de la nueva version del modulo

  • Propiedad mode establecida a 100644
File size: 1.7 KB
Línea 
1In Views areas (header, footer, empty-text) are pluggable, this means you can write your own php logic to place whatever you want.
2
3<h3>Requirements</h3>
4You should have read <a href="topic:views/api">API</a> and <a href="topic:views/api-tables">Tables API</a> to get a basic knowledge
5how to extend views.
6
7<h3>Create your own area handler</h3>
8
9The first step is to tell views: Hey i want to add a new area handler.
10Therefore you have to implement hook_views_data and add a new one. For example:
11
12<pre>
13function yourmodule_views_data() {
14  $data['views']['collapsible_area'] = array(
15    'title' =&gt; t('Collabsible Text area'),
16    'help' =&gt; t('Provide collabsible markup text for the area.'),
17    'area' =&gt; array(
18      'handler' =&gt; 'yourmodule_handler_collapsible_area_text',
19    ),
20  );
21}
22</pre>
23
24The second step is to write this handler. Therefore create a file called yourmodule_handler_collapsible_area_text.inc and
25add register your handler with hook_views_handlers, see <a href="topic:views/api-handlers">Handlers API</a>
26
27Then add content to your area file like this:
28<pre>
29class yourmodule_handler_collapsible_area_text extends views_handler_area_text {
30  function render($empty = FALSE) {
31    // Here you just return a string of your content you want.
32    if ($render = parent::render($empty)) {
33      $element = array(
34        '#type' =&gt; 'fieldset',
35        '#title' =&gt; t('Title'),
36        '#value' =&gt; $render,
37      );
38      $output = theme('fieldset', $element);
39      return $output;
40    }
41  }
42}
43</pre>
44
45As on every handler you can add options so you can configure the behavior. If the area isn't shown yet in the views interface, please clear the cache :)
Nota: Vea TracBrowser para ayuda de uso del navegador del repositorio.