aboutsummaryrefslogtreecommitdiffhomepage
path: root/doc/Plugin-System.html
diff options
context:
space:
mode:
Diffstat (limited to 'doc/Plugin-System.html')
-rw-r--r--doc/Plugin-System.html634
1 files changed, 0 insertions, 634 deletions
diff --git a/doc/Plugin-System.html b/doc/Plugin-System.html
deleted file mode 100644
index 123bf106..00000000
--- a/doc/Plugin-System.html
+++ /dev/null
@@ -1,634 +0,0 @@
1<!DOCTYPE html>
2<html>
3<head>
4 <meta charset="utf-8">
5 <meta name="generator" content="pandoc">
6 <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
7 <title>Shaarli – Plugin System</title>
8 <style type="text/css">code{white-space: pre;}</style>
9 <style type="text/css">
10div.sourceCode { overflow-x: auto; }
11table.sourceCode, tr.sourceCode, td.lineNumbers, td.sourceCode {
12 margin: 0; padding: 0; vertical-align: baseline; border: none; }
13table.sourceCode { width: 100%; line-height: 100%; }
14td.lineNumbers { text-align: right; padding-right: 4px; padding-left: 4px; color: #aaaaaa; border-right: 1px solid #aaaaaa; }
15td.sourceCode { padding-left: 5px; }
16code > span.kw { color: #007020; font-weight: bold; } /* Keyword */
17code > span.dt { color: #902000; } /* DataType */
18code > span.dv { color: #40a070; } /* DecVal */
19code > span.bn { color: #40a070; } /* BaseN */
20code > span.fl { color: #40a070; } /* Float */
21code > span.ch { color: #4070a0; } /* Char */
22code > span.st { color: #4070a0; } /* String */
23code > span.co { color: #60a0b0; font-style: italic; } /* Comment */
24code > span.ot { color: #007020; } /* Other */
25code > span.al { color: #ff0000; font-weight: bold; } /* Alert */
26code > span.fu { color: #06287e; } /* Function */
27code > span.er { color: #ff0000; font-weight: bold; } /* Error */
28code > span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warning */
29code > span.cn { color: #880000; } /* Constant */
30code > span.sc { color: #4070a0; } /* SpecialChar */
31code > span.vs { color: #4070a0; } /* VerbatimString */
32code > span.ss { color: #bb6688; } /* SpecialString */
33code > span.im { } /* Import */
34code > span.va { color: #19177c; } /* Variable */
35code > span.cf { color: #007020; font-weight: bold; } /* ControlFlow */
36code > span.op { color: #666666; } /* Operator */
37code > span.bu { } /* BuiltIn */
38code > span.ex { } /* Extension */
39code > span.pp { color: #bc7a00; } /* Preprocessor */
40code > span.at { color: #7d9029; } /* Attribute */
41code > span.do { color: #ba2121; font-style: italic; } /* Documentation */
42code > span.an { color: #60a0b0; font-weight: bold; font-style: italic; } /* Annotation */
43code > span.cv { color: #60a0b0; font-weight: bold; font-style: italic; } /* CommentVar */
44code > span.in { color: #60a0b0; font-weight: bold; font-style: italic; } /* Information */
45 </style>
46 <link rel="stylesheet" href="github-markdown.css">
47 <!--[if lt IE 9]>
48 <script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
49 <![endif]-->
50</head>
51<body>
52<div id="local-sidebar">
53<ul>
54<li><a href="Home.html">Home</a></li>
55<li>Setup
56<ul>
57<li><a href="Download-and-Installation.html">Download and Installation</a></li>
58<li><a href="Upgrade-and-migration.html">Upgrade and migration</a></li>
59<li><a href="Server-requirements.html">Server requirements</a></li>
60<li><a href="Server-configuration.html">Server configuration</a></li>
61<li><a href="Server-security.html">Server security</a></li>
62<li><a href="Shaarli-configuration.html">Shaarli configuration</a></li>
63<li><a href="Plugins.html">Plugins</a></li>
64</ul></li>
65<li><a href="Docker.html">Docker</a></li>
66<li><a href="Usage.html">Usage</a>
67<ul>
68<li><a href="Sharing-button.html">Sharing button</a> (bookmarklet)</li>
69<li><a href="Browsing-and-Searching.html">Browsing and Searching</a></li>
70<li><a href="Firefox-share.html">Firefox share</a></li>
71<li><a href="RSS-feeds.html">RSS feeds</a></li>
72<li><a href="REST-API.html">REST API</a></li>
73</ul></li>
74<li>How To
75<ul>
76<li><a href="Backup,-restore,-import-and-export.html">Backup, restore, import and export</a></li>
77<li><a href="Copy-an-existing-installation-over-SSH-and-serve-it-locally.html">Copy an existing installation over SSH and serve it locally</a></li>
78<li><a href="Create-and-serve-multiple-Shaarlis-(farm).html">Create and serve multiple Shaarlis (farm)</a></li>
79<li><a href="Download-CSS-styles-from-an-OPML-list.html">Download CSS styles from an OPML list</a></li>
80<li><a href="Datastore-hacks.html">Datastore hacks</a></li>
81</ul></li>
82<li><a href="Troubleshooting.html">Troubleshooting</a></li>
83<li><a href="Development.html">Development</a>
84<ul>
85<li><a href="GnuPG-signature.html">GnuPG signature</a></li>
86<li><a href="Coding-guidelines.html">Coding guidelines</a></li>
87<li><a href="Directory-structure.html">Directory structure</a></li>
88<li><a href="3rd-party-libraries.html">3rd party libraries</a></li>
89<li><a href="Plugin-System.html">Plugin System</a></li>
90<li><a href="Release-Shaarli.html">Release Shaarli</a></li>
91<li><a href="Versioning-and-Branches.html">Versioning and Branches</a></li>
92<li><a href="Security.html">Security</a></li>
93<li><a href="Static-analysis.html">Static analysis</a></li>
94<li><a href="Theming.html">Theming</a></li>
95<li><a href="Unit-tests.html">Unit tests</a></li>
96</ul></li>
97<li>About
98<ul>
99<li><a href="FAQ.html">FAQ</a></li>
100<li><a href="Community-&amp;-Related-software.html">Community &amp; Related software</a></li>
101</ul></li>
102</ul>
103</div>
104<h1 id="plugin-system">Plugin System</h1>
105<p><a href="#developer-api"><strong>I am a developer.</strong> Developer API.</a><a href=".html"></a></p>
106<p><a href="#guide-for-template-designer"><strong>I am a template designer.</strong> Guide for template designer.</a><a href=".html"></a></p>
107<h2 id="developer-api">Developer API</h2>
108<h3 id="what-can-i-do-with-plugins">What can I do with plugins?</h3>
109<p>The plugin system let you:</p>
110<ul>
111<li>insert content into specific places across templates.</li>
112<li>alter data before templates rendering.</li>
113<li>alter data before saving new links.</li>
114</ul>
115<h3 id="how-can-i-create-a-plugin-for-shaarli">How can I create a plugin for Shaarli?</h3>
116<p>First, chose a plugin name, such as <code>demo_plugin</code>.</p>
117<p>Under <code>plugin</code> folder, create a folder named with your plugin name. Then create a <plugin_name>.php file in that folder.</p>
118<p>You should have the following tree view:</p>
119<pre><code>| index.php
120| plugins/
121|---| demo_plugin/
122| |---| demo_plugin.php</code></pre>
123<h3 id="plugin-initialization">Plugin initialization</h3>
124<p>At the beginning of Shaarli execution, all enabled plugins are loaded. At this point, the plugin system looks for an <code>init()</code> function to execute and run it if it exists. This function must be named this way, and takes the <code>ConfigManager</code> as parameter.</p>
125<pre><code>&lt;plugin_name&gt;_init($conf)</code></pre>
126<p>This function can be used to create initial data, load default settings, etc. But also to set <em>plugin errors</em>. If the initialization function returns an array of strings, they will be understand as errors, and displayed in the header to logged in users.</p>
127<h3 id="understanding-hooks">Understanding hooks</h3>
128<p>A plugin is a set of functions. Each function will be triggered by the plugin system at certain point in Shaarli execution.</p>
129<p>These functions need to be named with this pattern:</p>
130<pre><code>hook_&lt;plugin_name&gt;_&lt;hook_name&gt;($data, $conf)</code></pre>
131<p>Parameters:</p>
132<ul>
133<li>data: see <a href="https://github.com/shaarli/Shaarli/wiki/Plugin-System#plugins-data">$data section</a><a href=".html"></a></li>
134<li>conf: the <code>ConfigManager</code> instance.</li>
135</ul>
136<p>For exemple, if my plugin want to add data to the header, this function is needed:</p>
137<pre><code>hook_demo_plugin_render_header</code></pre>
138<p>If this function is declared, and the plugin enabled, it will be called every time Shaarli is rendering the header.</p>
139<h3 id="plugins-data">Plugin's data</h3>
140<h4 id="parameters">Parameters</h4>
141<p>Every hook function has a <code>$data</code> parameter. Its content differs for each hooks.</p>
142<p><strong>This parameter needs to be returned every time</strong>, otherwise data is lost.</p>
143<pre><code>return $data;</code></pre>
144<h4 id="filling-templates-placeholder">Filling templates placeholder</h4>
145<p>Template placeholders are displayed in template in specific places.</p>
146<p>RainTPL displays every element contained in the placeholder's array. These element can be added by plugins.</p>
147<p>For example, let's add a value in the placeholder <code>top_placeholder</code> which is displayed at the top of my page:</p>
148<div class="sourceCode"><pre class="sourceCode php"><code class="sourceCode php"><span class="kw">$data</span><span class="ot">[</span><span class="st">&#39;top_placeholder&#39;</span><span class="ot">[]</span> = <span class="st">&#39;My content&#39;</span><span class="ot">;](]</span>-=-<span class="st">&#39;My-content&#39;</span><span class="ot">;</span>.html<span class="ot">)</span>
149<span class="co"># OR</span>
150<span class="fu">array_push</span><span class="ot">(</span><span class="kw">$data</span><span class="ot">[</span><span class="st">&#39;top_placeholder&#39;</span><span class="ot">],</span> <span class="st">&#39;My&#39;</span><span class="ot">,</span> <span class="st">&#39;content&#39;</span><span class="ot">);[](</span>.html<span class="ot">)</span>
151
152<span class="kw">return</span> <span class="kw">$data</span><span class="ot">;</span></code></pre></div>
153<h4 id="data-manipulation">Data manipulation</h4>
154<p>When a page is displayed, every variable send to the template engine is passed to plugins before that in <code>$data</code>.</p>
155<p>The data contained by this array can be altered before template rendering.</p>
156<p>For exemple, in linklist, it is possible to alter every title:</p>
157<div class="sourceCode"><pre class="sourceCode php"><code class="sourceCode php"><span class="co">// mind the reference if you want $data to be altered</span>
158<span class="kw">foreach</span> <span class="ot">(</span><span class="kw">$data</span><span class="ot">[</span><span class="st">&#39;links&#39;</span><span class="ot">]</span> <span class="kw">as</span> &amp;<span class="kw">$value</span><span class="ot">)</span> {<span class="ot">[](</span>.html<span class="ot">)</span>
159 <span class="co">// String reverse every title.</span>
160 <span class="kw">$value</span><span class="ot">[</span><span class="st">&#39;title&#39;</span><span class="ot">]</span> = <span class="fu">strrev</span><span class="ot">(</span><span class="kw">$value</span><span class="ot">[</span><span class="st">&#39;title&#39;</span><span class="ot">]);[](</span>.html<span class="ot">)</span>
161}
162
163<span class="kw">return</span> <span class="kw">$data</span><span class="ot">;</span></code></pre></div>
164<h3 id="metadata">Metadata</h3>
165<p>Every plugin needs a <code>&lt;plugin_name&gt;.meta</code> file, which is in fact an <code>.ini</code> file (<code>KEY=&quot;VALUE&quot;</code>), to be listed in plugin administration.</p>
166<p>Each file contain two keys:</p>
167<ul>
168<li><code>description</code>: plugin description</li>
169<li><code>parameters</code>: user parameter names, separated by a <code>;</code>.</li>
170<li><code>parameter.&lt;PARAMETER_NAME&gt;</code>: add a text description the specified parameter.</li>
171</ul>
172<blockquote>
173<p>Note: In PHP, <code>parse_ini_file()</code> seems to want strings to be between by quotes <code>&quot;</code> in the ini file.</p>
174</blockquote>
175<h3 id="its-not-working">It's not working!</h3>
176<p>Use <code>demo_plugin</code> as a functional example. It covers most of the plugin system features.</p>
177<p>If it's still not working, please <a href="https://github.com/shaarli/Shaarli/issues/new">open an issue</a>.<a href=".html"></a></p>
178<h3 id="hooks">Hooks</h3>
179<table style="width:42%;">
180<colgroup>
181<col style="width: 19%" />
182<col style="width: 22%" />
183</colgroup>
184<thead>
185<tr class="header">
186<th>Hooks</th>
187<th style="text-align: center;">Description</th>
188</tr>
189</thead>
190<tbody>
191<tr class="odd">
192<td><a href="#render_header">render_header</a></td>
193<td style="text-align: center;">Allow plugin to add content in page headers.</td>
194</tr>
195<tr class="even">
196<td><a href="#render_includes">render_includes</a></td>
197<td style="text-align: center;">Allow plugin to include their own CSS files.</td>
198</tr>
199<tr class="odd">
200<td><a href="#render_footer">render_footer</a></td>
201<td style="text-align: center;">Allow plugin to add content in page footer and include their own JS files.</td>
202</tr>
203<tr class="even">
204<td><a href="#render_linklist">render_linklist</a></td>
205<td style="text-align: center;">It allows to add content at the begining and end of the page, after every link displayed and to alter link data.</td>
206</tr>
207<tr class="odd">
208<td><a href="#render_editlink">render_editlink</a></td>
209<td style="text-align: center;">Allow to add fields in the form, or display elements.</td>
210</tr>
211<tr class="even">
212<td><a href="#render_tools">render_tools</a></td>
213<td style="text-align: center;">Allow to add content at the end of the page.</td>
214</tr>
215<tr class="odd">
216<td><a href="#render_picwall">render_picwall</a></td>
217<td style="text-align: center;">Allow to add content at the top and bottom of the page.</td>
218</tr>
219<tr class="even">
220<td><a href="#render_tagcloud">render_tagcloud</a></td>
221<td style="text-align: center;">Allow to add content at the top and bottom of the page, and after all tags.</td>
222</tr>
223<tr class="odd">
224<td><a href="#render_taglist">render_taglist</a></td>
225<td style="text-align: center;">Allow to add content at the top and bottom of the page, and after all tags.</td>
226</tr>
227<tr class="even">
228<td><a href="#render_daily">render_daily</a></td>
229<td style="text-align: center;">Allow to add content at the top and bottom of the page, the bottom of each link and to alter data.</td>
230</tr>
231<tr class="odd">
232<td><a href="#render_feed">render_feed</a></td>
233<td style="text-align: center;">Allow to do add tags in RSS and ATOM feeds.</td>
234</tr>
235<tr class="even">
236<td><a href="#save_link">save_link</a></td>
237<td style="text-align: center;">Allow to alter the link being saved in the datastore.</td>
238</tr>
239<tr class="odd">
240<td><a href="#delete_link">delete_link</a></td>
241<td style="text-align: center;">Allow to do an action before a link is deleted from the datastore.</td>
242</tr>
243</tbody>
244</table>
245<h4 id="render_header">render_header</h4>
246<p>Triggered on every page.</p>
247<p>Allow plugin to add content in page headers.</p>
248<h5 id="data">Data</h5>
249<p><code>$data</code> is an array containing:</p>
250<ul>
251<li><code>_PAGE_</code>: current target page (eg: <code>linklist</code>, <code>picwall</code>, etc.).</li>
252<li><code>_LOGGEDIN_</code>: true if user is logged in, false otherwise.</li>
253</ul>
254<h5 id="template-placeholders">Template placeholders</h5>
255<p>Items can be displayed in templates by adding an entry in <code>$data['&lt;placeholder&gt;']</code> array.<a href=".html"></a></p>
256<p>List of placeholders:</p>
257<ul>
258<li><code>buttons_toolbar</code>: after the list of buttons in the header.</li>
259</ul>
260<p><img src="http://i.imgur.com/ssJUOrt.png" alt="buttons_toolbar_example" /><a href=".html"></a></p>
261<ul>
262<li><code>fields_toolbar</code>: after search fields in the header.</li>
263</ul>
264<blockquote>
265<p>Note: This will only be called in linklist.</p>
266</blockquote>
267<p><img src="http://i.imgur.com/3GMifI2.png" alt="fields_toolbar_example" /><a href=".html"></a></p>
268<h4 id="render_includes">render_includes</h4>
269<p>Triggered on every page.</p>
270<p>Allow plugin to include their own CSS files.</p>
271<h5 id="data-1">Data</h5>
272<p><code>$data</code> is an array containing:</p>
273<ul>
274<li><code>_PAGE_</code>: current target page (eg: <code>linklist</code>, <code>picwall</code>, etc.).</li>
275<li><code>_LOGGEDIN_</code>: true if user is logged in, false otherwise.</li>
276</ul>
277<h5 id="template-placeholders-1">Template placeholders</h5>
278<p>Items can be displayed in templates by adding an entry in <code>$data['&lt;placeholder&gt;']</code> array.<a href=".html"></a></p>
279<p>List of placeholders:</p>
280<ul>
281<li><code>css_files</code>: called after loading default CSS.</li>
282</ul>
283<blockquote>
284<p>Note: only add the path of the CSS file. E.g: <code>plugins/demo_plugin/custom_demo.css</code>.</p>
285</blockquote>
286<h4 id="render_footer">render_footer</h4>
287<p>Triggered on every page.</p>
288<p>Allow plugin to add content in page footer and include their own JS files.</p>
289<h5 id="data-2">Data</h5>
290<p><code>$data</code> is an array containing:</p>
291<ul>
292<li><code>_PAGE_</code>: current target page (eg: <code>linklist</code>, <code>picwall</code>, etc.).</li>
293<li><code>_LOGGEDIN_</code>: true if user is logged in, false otherwise.</li>
294</ul>
295<h5 id="template-placeholders-2">Template placeholders</h5>
296<p>Items can be displayed in templates by adding an entry in <code>$data['&lt;placeholder&gt;']</code> array.<a href=".html"></a></p>
297<p>List of placeholders:</p>
298<ul>
299<li><code>text</code>: called after the end of the footer text.</li>
300<li><code>endofpage</code>: called at the end of the page.</li>
301</ul>
302<p><img src="http://i.imgur.com/L5S2YEH.png" alt="text_example" /><a href=".html"></a></p>
303<ul>
304<li><code>js_files</code>: called at the end of the page, to include custom JS scripts.</li>
305</ul>
306<blockquote>
307<p>Note: only add the path of the JS file. E.g: <code>plugins/demo_plugin/custom_demo.js</code>.</p>
308</blockquote>
309<h4 id="render_linklist">render_linklist</h4>
310<p>Triggered when <code>linklist</code> is displayed (list of links, permalink, search, tag filtered, etc.).</p>
311<p>It allows to add content at the begining and end of the page, after every link displayed and to alter link data.</p>
312<h5 id="data-3">Data</h5>
313<p><code>$data</code> is an array containing:</p>
314<ul>
315<li><code>_LOGGEDIN_</code>: true if user is logged in, false otherwise.</li>
316<li>All templates data, including links.</li>
317</ul>
318<h5 id="template-placeholders-3">Template placeholders</h5>
319<p>Items can be displayed in templates by adding an entry in <code>$data['&lt;placeholder&gt;']</code> array.<a href=".html"></a></p>
320<p>List of placeholders:</p>
321<ul>
322<li><code>action_plugin</code>: next to the button &quot;private only&quot; at the top and bottom of the page.</li>
323</ul>
324<p><img src="http://i.imgur.com/Q12PWg0.png" alt="action_plugin_example" /><a href=".html"></a></p>
325<ul>
326<li><code>link_plugin</code>: for every link, between permalink and link URL.</li>
327</ul>
328<p><img src="http://i.imgur.com/3oDPhWx.png" alt="link_plugin_example" /><a href=".html"></a></p>
329<ul>
330<li><code>plugin_start_zone</code>: before displaying the template content.</li>
331</ul>
332<p><img src="http://i.imgur.com/OVBkGy3.png" alt="plugin_start_zone_example" /><a href=".html"></a></p>
333<ul>
334<li><code>plugin_end_zone</code>: after displaying the template content.</li>
335</ul>
336<p><img src="http://i.imgur.com/6IoRuop.png" alt="plugin_end_zone_example" /><a href=".html"></a></p>
337<h4 id="render_editlink">render_editlink</h4>
338<p>Triggered when the link edition form is displayed.</p>
339<p>Allow to add fields in the form, or display elements.</p>
340<h5 id="data-4">Data</h5>
341<p><code>$data</code> is an array containing:</p>
342<ul>
343<li>All templates data.</li>
344</ul>
345<h5 id="template-placeholders-4">Template placeholders</h5>
346<p>Items can be displayed in templates by adding an entry in <code>$data['&lt;placeholder&gt;']</code> array.<a href=".html"></a></p>
347<p>List of placeholders:</p>
348<ul>
349<li><code>edit_link_plugin</code>: after tags field.</li>
350</ul>
351<p><img src="http://i.imgur.com/5u17Ens.png" alt="edit_link_plugin_example" /><a href=".html"></a></p>
352<h4 id="render_tools">render_tools</h4>
353<p>Triggered when the &quot;tools&quot; page is displayed.</p>
354<p>Allow to add content at the end of the page.</p>
355<h5 id="data-5">Data</h5>
356<p><code>$data</code> is an array containing:</p>
357<ul>
358<li>All templates data.</li>
359</ul>
360<h5 id="template-placeholders-5">Template placeholders</h5>
361<p>Items can be displayed in templates by adding an entry in <code>$data['&lt;placeholder&gt;']</code> array.<a href=".html"></a></p>
362<p>List of placeholders:</p>
363<ul>
364<li><code>tools_plugin</code>: at the end of the page.</li>
365</ul>
366<p><img src="http://i.imgur.com/Bqhu9oQ.png" alt="tools_plugin_example" /><a href=".html"></a></p>
367<h4 id="render_picwall">render_picwall</h4>
368<p>Triggered when picwall is displayed.</p>
369<p>Allow to add content at the top and bottom of the page.</p>
370<h5 id="data-6">Data</h5>
371<p><code>$data</code> is an array containing:</p>
372<ul>
373<li><code>_LOGGEDIN_</code>: true if user is logged in, false otherwise.</li>
374<li>All templates data.</li>
375</ul>
376<h5 id="template-placeholders-6">Template placeholders</h5>
377<p>Items can be displayed in templates by adding an entry in <code>$data['&lt;placeholder&gt;']</code> array.<a href=".html"></a></p>
378<p>List of placeholders:</p>
379<ul>
380<li><p><code>plugin_start_zone</code>: before displaying the template content.</p></li>
381<li><p><code>plugin_end_zone</code>: after displaying the template content.</p></li>
382</ul>
383<p><img src="http://i.imgur.com/tVTQFER.png" alt="plugin_start_end_zone_example" /><a href=".html"></a></p>
384<h4 id="render_tagcloud">render_tagcloud</h4>
385<p>Triggered when tagcloud is displayed.</p>
386<p>Allow to add content at the top and bottom of the page.</p>
387<h5 id="data-7">Data</h5>
388<p><code>$data</code> is an array containing:</p>
389<ul>
390<li><code>_LOGGEDIN_</code>: true if user is logged in, false otherwise.</li>
391<li>All templates data.</li>
392</ul>
393<h5 id="template-placeholders-7">Template placeholders</h5>
394<p>Items can be displayed in templates by adding an entry in <code>$data['&lt;placeholder&gt;']</code> array.<a href=".html"></a></p>
395<p>List of placeholders:</p>
396<ul>
397<li><p><code>plugin_start_zone</code>: before displaying the template content.</p></li>
398<li><p><code>plugin_end_zone</code>: after displaying the template content.</p></li>
399</ul>
400<p>For each tag, the following placeholder can be used:</p>
401<ul>
402<li><code>tag_plugin</code>: after each tag</li>
403</ul>
404<p><img src="http://i.imgur.com/vHmyT3a.png" alt="plugin_start_end_zone_example" /><a href=".html"></a></p>
405<h4 id="render_taglist">render_taglist</h4>
406<p>Triggered when taglist is displayed.</p>
407<p>Allow to add content at the top and bottom of the page.</p>
408<h5 id="data-8">Data</h5>
409<p><code>$data</code> is an array containing:</p>
410<ul>
411<li><code>_LOGGEDIN_</code>: true if user is logged in, false otherwise.</li>
412<li>All templates data.</li>
413</ul>
414<h5 id="template-placeholders-8">Template placeholders</h5>
415<p>Items can be displayed in templates by adding an entry in <code>$data['&lt;placeholder&gt;']</code> array.<a href=".html"></a></p>
416<p>List of placeholders:</p>
417<ul>
418<li><p><code>plugin_start_zone</code>: before displaying the template content.</p></li>
419<li><p><code>plugin_end_zone</code>: after displaying the template content.</p></li>
420</ul>
421<p>For each tag, the following placeholder can be used:</p>
422<ul>
423<li><code>tag_plugin</code>: after each tag</li>
424</ul>
425<h4 id="render_daily">render_daily</h4>
426<p>Triggered when tagcloud is displayed.</p>
427<p>Allow to add content at the top and bottom of the page, the bottom of each link and to alter data.</p>
428<h5 id="data-9">Data</h5>
429<p><code>$data</code> is an array containing:</p>
430<ul>
431<li><code>_LOGGEDIN_</code>: true if user is logged in, false otherwise.</li>
432<li>All templates data, including links.</li>
433</ul>
434<h5 id="template-placeholders-9">Template placeholders</h5>
435<p>Items can be displayed in templates by adding an entry in <code>$data['&lt;placeholder&gt;']</code> array.<a href=".html"></a></p>
436<p>List of placeholders:</p>
437<ul>
438<li><code>link_plugin</code>: used at bottom of each link.</li>
439</ul>
440<p><img src="http://i.imgur.com/hzhMfSZ.png" alt="link_plugin_example" /><a href=".html"></a></p>
441<ul>
442<li><p><code>plugin_start_zone</code>: before displaying the template content.</p></li>
443<li><p><code>plugin_end_zone</code>: after displaying the template content.</p></li>
444</ul>
445<h4 id="render_feed">render_feed</h4>
446<p>Triggered when the ATOM or RSS feed is displayed.</p>
447<p>Allow to add tags in the feed, either in the header or for each items. Items (links) can also be altered before being rendered.</p>
448<h5 id="data-10">Data</h5>
449<p><code>$data</code> is an array containing:</p>
450<ul>
451<li><code>_LOGGEDIN_</code>: true if user is logged in, false otherwise.</li>
452<li><code>_PAGE_</code>: containing either <code>rss</code> or <code>atom</code>.</li>
453<li>All templates data, including links.</li>
454</ul>
455<h5 id="template-placeholders-10">Template placeholders</h5>
456<p>Tags can be added in feeds by adding an entry in <code>$data['&lt;placeholder&gt;']</code> array.<a href=".html"></a></p>
457<p>List of placeholders:</p>
458<ul>
459<li><code>feed_plugins_header</code>: used as a header tag in the feed.</li>
460</ul>
461<p>For each links:</p>
462<ul>
463<li><code>feed_plugins</code>: additional tag for every link entry.</li>
464</ul>
465<h4 id="save_link">save_link</h4>
466<p>Triggered when a link is save (new link or edit).</p>
467<p>Allow to alter the link being saved in the datastore.</p>
468<h5 id="data-11">Data</h5>
469<p><code>$data</code> is an array containing the link being saved:</p>
470<ul>
471<li>id</li>
472<li>title</li>
473<li>url</li>
474<li>shorturl</li>
475<li>description</li>
476<li>private</li>
477<li>tags</li>
478<li>created</li>
479<li>updated</li>
480</ul>
481<h4 id="delete_link">delete_link</h4>
482<p>Triggered when a link is deleted.</p>
483<p>Allow to execute any action before the link is actually removed from the datastore</p>
484<h5 id="data-12">Data</h5>
485<p><code>$data</code> is an array containing the link being saved:</p>
486<ul>
487<li>id</li>
488<li>title</li>
489<li>url</li>
490<li>shorturl</li>
491<li>description</li>
492<li>private</li>
493<li>tags</li>
494<li>created</li>
495<li>updated</li>
496</ul>
497<h2 id="guide-for-template-designer">Guide for template designer</h2>
498<h3 id="plugin-administration">Plugin administration</h3>
499<p>Your theme must include a plugin administration page: <code>pluginsadmin.html</code>.</p>
500<blockquote>
501<p>Note: repo's template link needs to be added when the PR is merged.</p>
502</blockquote>
503<p>Use the default one as an example.</p>
504<p>Aside from classic RainTPL loops, plugins order is handle by JavaScript. You can just include <code>plugin_admin.js</code>, only if:</p>
505<ul>
506<li>you're using a table.</li>
507<li>you call orderUp() and orderUp() onclick on arrows.</li>
508<li>you add data-line and data-order to your rows.</li>
509</ul>
510<p>Otherwise, you can use your own JS as long as this field is send by the form:</p>
511<p><input type="hidden" name="order_{$key}" value="{$counter}"></p>
512<h3 id="placeholder-system">Placeholder system</h3>
513<p>In order to make plugins work with every custom themes, you need to add variable placeholder in your templates.</p>
514<p>It's a RainTPL loop like this:</p>
515<pre><code>{loop=&quot;$plugin_variable&quot;}
516 {$value}
517{/loop}</code></pre>
518<p>You should enable <code>demo_plugin</code> for testing purpose, since it uses every placeholder available.</p>
519<h3 id="list-of-placeholders">List of placeholders</h3>
520<p><strong>page.header.html</strong></p>
521<p>At the end of the menu:</p>
522<pre><code>{loop=&quot;$plugins_header.buttons_toolbar&quot;}
523 {$value}
524{/loop}</code></pre>
525<p>At the end of file, before clearing floating blocks:</p>
526<pre><code>{if=&quot;!empty($plugin_errors) &amp;&amp; isLoggedIn()&quot;}
527 &lt;ul class=&quot;errors&quot;&gt;
528 {loop=&quot;plugin_errors&quot;}
529 &lt;li&gt;{$value}&lt;/li&gt;
530 {/loop}
531 &lt;/ul&gt;
532{/if}</code></pre>
533<p><strong>includes.html</strong></p>
534<p>At the end of the file:</p>
535<div class="sourceCode"><pre class="sourceCode html"><code class="sourceCode html">{loop=&quot;$plugins_includes.css_files&quot;}
536<span class="kw">&lt;link</span><span class="ot"> type=</span><span class="st">&quot;text/css&quot;</span><span class="ot"> rel=</span><span class="st">&quot;stylesheet&quot;</span><span class="ot"> href=</span><span class="st">&quot;{$value}#&quot;</span><span class="kw">/&gt;</span>
537{/loop}</code></pre></div>
538<p><strong>page.footer.html</strong></p>
539<p>At the end of your footer notes:</p>
540<div class="sourceCode"><pre class="sourceCode html"><code class="sourceCode html">{loop=&quot;$plugins_footer.text&quot;}
541 {$value}
542{/loop}</code></pre></div>
543<p>At the end of file:</p>
544<div class="sourceCode"><pre class="sourceCode html"><code class="sourceCode html">{loop=&quot;$plugins_footer.js_files&quot;}
545 <span class="kw">&lt;script</span><span class="ot"> src=</span><span class="st">&quot;{$value}#&quot;</span><span class="kw">&gt;&lt;/script&gt;</span>
546{/loop}</code></pre></div>
547<p><strong>linklist.html</strong></p>
548<p>After search fields:</p>
549<div class="sourceCode"><pre class="sourceCode html"><code class="sourceCode html">{loop=&quot;$plugins_header.fields_toolbar&quot;}
550 {$value}
551{/loop}</code></pre></div>
552<p>Before displaying the link list (after paging):</p>
553<div class="sourceCode"><pre class="sourceCode html"><code class="sourceCode html">{loop=&quot;$plugin_start_zone&quot;}
554 {$value}
555{/loop}</code></pre></div>
556<p>For every links (icons):</p>
557<div class="sourceCode"><pre class="sourceCode html"><code class="sourceCode html">{loop=&quot;$value.link_plugin&quot;}
558 <span class="kw">&lt;span&gt;</span>{$value}<span class="kw">&lt;/span&gt;</span>
559{/loop}</code></pre></div>
560<p>Before end paging:</p>
561<div class="sourceCode"><pre class="sourceCode html"><code class="sourceCode html">{loop=&quot;$plugin_end_zone&quot;}
562 {$value}
563{/loop}</code></pre></div>
564<p><strong>linklist.paging.html</strong></p>
565<p>After the &quot;private only&quot; icon:</p>
566<div class="sourceCode"><pre class="sourceCode html"><code class="sourceCode html">{loop=&quot;$action_plugin&quot;}
567 {$value}
568{/loop}</code></pre></div>
569<p><strong>editlink.html</strong></p>
570<p>After tags field:</p>
571<div class="sourceCode"><pre class="sourceCode html"><code class="sourceCode html">{loop=&quot;$edit_link_plugin&quot;}
572 {$value}
573{/loop}</code></pre></div>
574<p><strong>tools.html</strong></p>
575<p>After the last tool:</p>
576<div class="sourceCode"><pre class="sourceCode html"><code class="sourceCode html">{loop=&quot;$tools_plugin&quot;}
577 {$value}
578{/loop}</code></pre></div>
579<p><strong>picwall.html</strong></p>
580<p>Top:</p>
581<div class="sourceCode"><pre class="sourceCode html"><code class="sourceCode html"><span class="kw">&lt;div</span><span class="ot"> id=</span><span class="st">&quot;plugin_zone_start_picwall&quot;</span><span class="ot"> class=</span><span class="st">&quot;plugin_zone&quot;</span><span class="kw">&gt;</span>
582 {loop=&quot;$plugin_start_zone&quot;}
583 {$value}
584 {/loop}
585<span class="kw">&lt;/div&gt;</span></code></pre></div>
586<p>Bottom:</p>
587<div class="sourceCode"><pre class="sourceCode html"><code class="sourceCode html"><span class="kw">&lt;div</span><span class="ot"> id=</span><span class="st">&quot;plugin_zone_end_picwall&quot;</span><span class="ot"> class=</span><span class="st">&quot;plugin_zone&quot;</span><span class="kw">&gt;</span>
588 {loop=&quot;$plugin_end_zone&quot;}
589 {$value}
590 {/loop}
591<span class="kw">&lt;/div&gt;</span></code></pre></div>
592<p><strong>tagcloud.html</strong></p>
593<p>Top:</p>
594<div class="sourceCode"><pre class="sourceCode html"><code class="sourceCode html"> <span class="kw">&lt;div</span><span class="ot"> id=</span><span class="st">&quot;plugin_zone_start_tagcloud&quot;</span><span class="ot"> class=</span><span class="st">&quot;plugin_zone&quot;</span><span class="kw">&gt;</span>
595 {loop=&quot;$plugin_start_zone&quot;}
596 {$value}
597 {/loop}
598 <span class="kw">&lt;/div&gt;</span></code></pre></div>
599<p>Bottom:</p>
600<div class="sourceCode"><pre class="sourceCode html"><code class="sourceCode html"> <span class="kw">&lt;div</span><span class="ot"> id=</span><span class="st">&quot;plugin_zone_end_tagcloud&quot;</span><span class="ot"> class=</span><span class="st">&quot;plugin_zone&quot;</span><span class="kw">&gt;</span>
601 {loop=&quot;$plugin_end_zone&quot;}
602 {$value}
603 {/loop}
604 <span class="kw">&lt;/div&gt;</span></code></pre></div>
605<p><strong>daily.html</strong></p>
606<p>Top:</p>
607<div class="sourceCode"><pre class="sourceCode html"><code class="sourceCode html"><span class="kw">&lt;div</span><span class="ot"> id=</span><span class="st">&quot;plugin_zone_start_picwall&quot;</span><span class="ot"> class=</span><span class="st">&quot;plugin_zone&quot;</span><span class="kw">&gt;</span>
608 {loop=&quot;$plugin_start_zone&quot;}
609 {$value}
610 {/loop}
611<span class="kw">&lt;/div&gt;</span></code></pre></div>
612<p>After every link:</p>
613<div class="sourceCode"><pre class="sourceCode html"><code class="sourceCode html"><span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">&quot;dailyEntryFooter&quot;</span><span class="kw">&gt;</span>
614 {loop=&quot;$link.link_plugin&quot;}
615 {$value}
616 {/loop}
617<span class="kw">&lt;/div&gt;</span></code></pre></div>
618<p>Bottom:</p>
619<div class="sourceCode"><pre class="sourceCode html"><code class="sourceCode html"><span class="kw">&lt;div</span><span class="ot"> id=</span><span class="st">&quot;plugin_zone_end_picwall&quot;</span><span class="ot"> class=</span><span class="st">&quot;plugin_zone&quot;</span><span class="kw">&gt;</span>
620 {loop=&quot;$plugin_end_zone&quot;}
621 {$value}
622 {/loop}
623<span class="kw">&lt;/div&gt;</span></code></pre></div>
624<p><strong>feed.atom.xml</strong> and <strong>feed.rss.xml</strong>:</p>
625<p>In headers tags section:</p>
626<div class="sourceCode"><pre class="sourceCode xml"><code class="sourceCode xml">{loop=&quot;$feed_plugins_header&quot;}
627 {$value}
628{/loop}</code></pre></div>
629<p>After each entry:</p>
630<div class="sourceCode"><pre class="sourceCode xml"><code class="sourceCode xml">{loop=&quot;$value.feed_plugins&quot;}
631 {$value}
632{/loop}</code></pre></div>
633</body>
634</html>