summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Wehner2011-10-26 07:49:08 (GMT)
committer Daniel Wehner2011-10-26 07:50:16 (GMT)
commitdeda5b41bf5d5383c473b1dc2eed271ca9289163 (patch)
tree82cd48d9278246cd1e514ad3c009dc498fd12dbf
parent2d21adf9182a63254322044f263c656963a18342 (diff)
by dereine: Describe how to write an area handler
-rw-r--r--help/api-handler-area.html45
-rw-r--r--help/views.help.ini5
2 files changed, 50 insertions, 0 deletions
diff --git a/help/api-handler-area.html b/help/api-handler-area.html
new file mode 100644
index 0000000..41fd473
--- /dev/null
+++ b/help/api-handler-area.html
@@ -0,0 +1,45 @@
+In Views areas (header, footer, empty-text) are pluggable, this means you can write your own php logic to place whatever you want.
+
+<h3>Requirements</h3>
+You 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
+how to extend views.
+
+<h3>Create your own area handler</h3>
+
+The first step is to tell views: Hey i want to add a new area handler.
+Therefore you have to implement hook_views_data and add a new one. For example:
+
+<pre>
+function yourmodule_views_data() {
+ $data['views']['collapsible_area'] = array(
+ 'title' =&gt; t('Collabsible Text area'),
+ 'help' =&gt; t('Provide collabsible markup text for the area.'),
+ 'area' =&gt; array(
+ 'handler' =&gt; 'yourmodule_handler_collapsible_area_text',
+ ),
+ );
+}
+</pre>
+
+The second step is to write this handler. Therefore create a file called yourmodule_handler_collapsible_area_text.inc and
+add register your handler with hook_views_handlers, see <a href="topic:views/api-handlers">Handlers API</a>
+
+Then add content to your area file like this:
+<pre>
+class yourmodule_handler_collapsible_area_text extends views_handler_area_text {
+ function render($empty = FALSE) {
+ // Here you just return a string of your content you want.
+ if ($render = parent::render($empty)) {
+ $element = array(
+ '#type' =&gt; 'fieldset',
+ '#title' =&gt; t('Title'),
+ '#value' =&gt; $render,
+ );
+ $output = theme('fieldset', $element);
+ return $output;
+ }
+ }
+}
+</pre>
+
+As 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 :) \ No newline at end of file
diff --git a/help/views.help.ini b/help/views.help.ini
index fd35687..40f79ff 100644
--- a/help/views.help.ini
+++ b/help/views.help.ini
@@ -260,6 +260,11 @@ title = "How Views handlers work"
weight = -50
parent = api
+[api-handler-area]
+title = "How to write an area handler"
+weight = -40
+parent = api
+
[api-plugins]
title = "How Views plugins work"
weight = -40