aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfriendica <info@friendica.com>2013-10-16 21:00:14 -0700
committerfriendica <info@friendica.com>2013-10-16 21:00:14 -0700
commitda738134875ac9a5640b2361d18146283da784e4 (patch)
tree62884e56a244ed4c527ca5273e208bb5c1bd700b
parenta104a7877b09e0c4963e30b1fd91e2fa6db9ac36 (diff)
downloadvolse-hubzilla-da738134875ac9a5640b2361d18146283da784e4.tar.gz
volse-hubzilla-da738134875ac9a5640b2361d18146283da784e4.tar.bz2
volse-hubzilla-da738134875ac9a5640b2361d18146283da784e4.zip
advanced plugins as a stepping stone to building modules
-rw-r--r--doc/Plugins.md36
1 files changed, 35 insertions, 1 deletions
diff --git a/doc/Plugins.md b/doc/Plugins.md
index 80379c478..aec4c8399 100644
--- a/doc/Plugins.md
+++ b/doc/Plugins.md
@@ -207,4 +207,38 @@ Now let's add our functions to create and store preference settings.
- \ No newline at end of file
+***Advanced Plugins***
+
+Sometimes your plugins want to provide a range of new functionality which isn't provided at all or is clumsy to provide using hooks. In this case your plugin can also act as a 'module'. A module in our case refers to a structured webpage handler which responds to a given URL. Then anything which accesses that URL will be handled completely by your plugin.
+
+The key to this is to create a simple function named pluginname_module() which does nothing.
+
+ function randplace_module() { return; }
+
+Once this function exists, the URL https://yoursite/randplace will access your plugin as a module. Then you can define functions which are called at various points to build a webpage just like the modules in the mod/ directory. The typical functions and the order which they are called is
+
+ modulename_init($a) // (e.g. randplace_init($a);) called first - if you wish to emit json or xml,
+ // you should do it here, followed by killme() which will avoid the default action of building a webpage
+ modulename_aside($a) // Often used to create sidebar content
+ modulename_post($a) // Called whenever the page is accessed via the "post" method
+ modulename_content($a) // called to generate the central page content. This function should return a string
+ // consisting of the central page content.
+
+Your module functions have access to the URL path as if they were standalone programs in the Unix operating system. For instance if you visit the page
+
+ https://yoursite/randplace/something/somewhere/whatever
+
+we will create an argc/argv list for use by your module functions
+
+ $x = argc(); $x will be 4, the number of path arguments after the sitename
+
+ for($x = 0; $x < argc(); $x ++)
+ echo $x . ' ' . argv($x);
+
+
+ 0 randplace
+ 1 something
+ 2 somewhere
+ 3 whatever
+
+