]> git.immae.eu Git - github/shaarli/Shaarli.git/blame - doc/Plugin-System.html
Doc update
[github/shaarli/Shaarli.git] / doc / Plugin-System.html
CommitLineData
992af0b9
V
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">
5409ade2 7 <title>Shaarli – Plugin System</title>
992af0b9 8 <style type="text/css">code{white-space: pre;}</style>
992af0b9 9 <style type="text/css">
5409ade2 10div.sourceCode { overflow-x: auto; }
992af0b9
V
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; }
5409ade2
A
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 */
992af0b9
V
45 </style>
46 <link rel="stylesheet" href="github-markdown.css">
5409ade2
A
47 <!--[if lt IE 9]>
48 <script src="//cdnjs.cloudflare.com/ajax/libs/html5shiv/3.7.3/html5shiv-printshiv.min.js"></script>
49 <![endif]-->
992af0b9
V
50</head>
51<body>
52<div id="local-sidebar">
53<ul>
54<li><a href="Home.html">Home</a></li>
55<li>Installation
56<ul>
f8b936e7 57<li><a href="Download.html">Download</a></li>
992af0b9
V
58<li><a href="Server-requirements.html">Server requirements</a></li>
59<li><a href="Server-configuration.html">Server configuration</a></li>
5409ade2
A
60<li><a href="Server-security.html">Server security</a></li>
61<li><a href="Shaarli-installation.html">Shaarli installation</a></li>
992af0b9 62<li><a href="Shaarli-configuration.html">Shaarli configuration</a></li>
08dcd8ea 63<li><a href="Plugins.html">Plugins</a></li>
992af0b9 64</ul></li>
5409ade2 65<li><a href="Docker.html">Docker</a></li>
992af0b9
V
66<li><a href="Usage.html">Usage</a>
67<ul>
68<li><a href="Sharing-button.html">Sharing button</a> (bookmarklet)</li>
5409ade2 69<li><a href="Browsing-and-Searching.html">Browsing and Searching</a></li>
992af0b9
V
70<li><a href="Firefox-share.html">Firefox share</a></li>
71<li><a href="RSS-feeds.html">RSS feeds</a></li>
72</ul></li>
73<li>How To
74<ul>
75<li><a href="Backup,-restore,-import-and-export.html">Backup, restore, import and export</a></li>
5409ade2 76<li><a href="Upgrade-from-original-sebsauvage/Shaarli.html">Upgrade from original sebsauvage/Shaarli</a></li>
992af0b9 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>
5409ade2 78<li><a href="Create-and-serve-multiple-Shaarlis-(farm).html">Create and serve multiple Shaarlis (farm)</a></li>
992af0b9 79<li><a href="Download-CSS-styles-from-an-OPML-list.html">Download CSS styles from an OPML list</a></li>
6335a0fc 80<li><a href="Datastore-hacks.html">Datastore hacks</a></li>
992af0b9
V
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>
5409ade2 90<li><a href="Release-Shaarli.html">Release Shaarli</a></li>
992af0b9
V
91<li><a href="Security.html">Security</a></li>
92<li><a href="Static-analysis.html">Static analysis</a></li>
93<li><a href="Theming.html">Theming</a></li>
94<li><a href="Unit-tests.html">Unit tests</a></li>
95</ul></li>
96<li>About
97<ul>
98<li><a href="FAQ.html">FAQ</a></li>
99<li><a href="Community-&amp;-Related-software.html">Community &amp; Related software</a></li>
100<li><a href="TODO.html">TODO</a></li>
101</ul></li>
102</ul>
103</div>
104<h1 id="plugin-system">Plugin System</h1>
105<blockquote>
5409ade2 106<p>Note: Plugin current status - in development (not merged into master).</p>
992af0b9 107</blockquote>
5409ade2 108<p><a href="#developer-api"><strong>I am a developer.</strong> Developer API.</a><a href=".html"></a></p>
992af0b9 109<p><a href="#guide-for-template-designer"><strong>I am a template designer.</strong> Guide for template designer.</a><a href=".html"></a></p>
5409ade2 110<h2 id="developer-api">Developer API</h2>
992af0b9
V
111<h3 id="what-can-i-do-with-plugins">What can I do with plugins?</h3>
112<p>The plugin system let you:</p>
113<ul>
114<li>insert content into specific places across templates.</li>
115<li>alter data before templates rendering.</li>
116<li>alter data before saving new links.</li>
117</ul>
118<h3 id="how-can-i-create-a-plugin-for-shaarli">How can I create a plugin for Shaarli?</h3>
119<p>First, chose a plugin name, such as <code>demo_plugin</code>.</p>
120<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>
121<p>You should have the following tree view:</p>
122<pre><code>| index.php
123| plugins/
124|---| demo_plugin/
125| |---| demo_plugin.php</code></pre>
126<h3 id="understanding-hooks">Understanding hooks</h3>
127<p>A plugin is a set of functions. Each function will be triggered by the plugin system at certain point in Shaarli execution.</p>
128<p>These functions need to be named with this pattern:</p>
129<pre><code>hook_&lt;plugin_name&gt;_&lt;hook_name&gt;</code></pre>
130<p>For exemple, if my plugin want to add data to the header, this function is needed:</p>
131<pre><code>hook_demo_plugin_render_header()</code></pre>
132<p>If this function is declared, and the plugin enabled, it will be called every time Shaarli is rendering the header.</p>
133<h3 id="plugins-data">Plugin's data</h3>
134<h4 id="parameters">Parameters</h4>
135<p>Every hook function has a <code>$data</code> parameter. Its content differs for each hooks.</p>
136<p><strong>This parameter needs to be returned every time</strong>, otherwise data is lost.</p>
137<pre><code>return $data;</code></pre>
138<h4 id="filling-templates-placeholder">Filling templates placeholder</h4>
139<p>Template placeholders are displayed in template in specific places.</p>
140<p>RainTPL displays every element contained in the placeholder's array. These element can be added by plugins.</p>
141<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>
5409ade2 142<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>
992af0b9
V
143<span class="co"># OR</span>
144<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>
145
5409ade2 146<span class="kw">return</span> <span class="kw">$data</span><span class="ot">;</span></code></pre></div>
992af0b9
V
147<h4 id="data-manipulation">Data manipulation</h4>
148<p>When a page is displayed, every variable send to the template engine is passed to plugins before that in <code>$data</code>.</p>
149<p>The data contained by this array can be altered before template rendering.</p>
150<p>For exemple, in linklist, it is possible to alter every title:</p>
5409ade2 151<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>
992af0b9
V
152<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>
153 <span class="co">// String reverse every title.</span>
154 <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>
155}
156
5409ade2
A
157<span class="kw">return</span> <span class="kw">$data</span><span class="ot">;</span></code></pre></div>
158<h3 id="metadata">Metadata</h3>
159<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>
160<p>Each file contain two keys:</p>
161<ul>
162<li><code>description</code>: plugin description</li>
163<li><code>parameters</code>: user parameter names, separated by a <code>;</code>.</li>
164</ul>
165<blockquote>
166<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>
167</blockquote>
992af0b9
V
168<h3 id="its-not-working">It's not working!</h3>
169<p>Use <code>demo_plugin</code> as a functional example. It covers most of the plugin system features.</p>
170<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>
171<h3 id="hooks">Hooks</h3>
5409ade2
A
172<table style="width:42%;">
173<colgroup>
174<col style="width: 19%" />
175<col style="width: 22%" />
176</colgroup>
992af0b9
V
177<thead>
178<tr class="header">
5409ade2 179<th>Hooks</th>
992af0b9
V
180<th style="text-align: center;">Description</th>
181</tr>
182</thead>
183<tbody>
184<tr class="odd">
5409ade2 185<td><a href="#render_header">render_header</a></td>
992af0b9
V
186<td style="text-align: center;">Allow plugin to add content in page headers.</td>
187</tr>
188<tr class="even">
5409ade2 189<td><a href="#render_includes">render_includes</a></td>
992af0b9
V
190<td style="text-align: center;">Allow plugin to include their own CSS files.</td>
191</tr>
192<tr class="odd">
5409ade2 193<td><a href="#render_footer">render_footer</a></td>
992af0b9
V
194<td style="text-align: center;">Allow plugin to add content in page footer and include their own JS files.</td>
195</tr>
196<tr class="even">
5409ade2 197<td><a href="#render_linklist">render_linklist</a></td>
992af0b9
V
198<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>
199</tr>
200<tr class="odd">
5409ade2 201<td><a href="#render_editlink">render_editlink</a></td>
992af0b9
V
202<td style="text-align: center;">Allow to add fields in the form, or display elements.</td>
203</tr>
204<tr class="even">
5409ade2 205<td><a href="#render_tools">render_tools</a></td>
992af0b9
V
206<td style="text-align: center;">Allow to add content at the end of the page.</td>
207</tr>
208<tr class="odd">
5409ade2 209<td><a href="#render_picwall">render_picwall</a></td>
992af0b9
V
210<td style="text-align: center;">Allow to add content at the top and bottom of the page.</td>
211</tr>
212<tr class="even">
5409ade2 213<td><a href="#render_tagcloud">render_tagcloud</a></td>
992af0b9
V
214<td style="text-align: center;">Allow to add content at the top and bottom of the page.</td>
215</tr>
216<tr class="odd">
5409ade2 217<td><a href="#render_daily">render_daily</a></td>
992af0b9
V
218<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>
219</tr>
220<tr class="even">
5409ade2 221<td><a href="#savelink">savelink</a></td>
992af0b9
V
222<td style="text-align: center;">Allow to alter the link being saved in the datastore.</td>
223</tr>
224</tbody>
225</table>
226<h4 id="render_header">render_header</h4>
227<p>Triggered on every page.</p>
228<p>Allow plugin to add content in page headers.</p>
229<h5 id="data">Data</h5>
230<p><code>$data</code> is an array containing:</p>
231<ul>
232<li><code>_PAGE_</code>: current target page (eg: <code>linklist</code>, <code>picwall</code>, etc.).</li>
233<li><code>_LOGGEDIN_</code>: true if user is logged in, false otherwise.</li>
234</ul>
235<h5 id="template-placeholders">Template placeholders</h5>
236<p>Items can be displayed in templates by adding an entry in <code>$data['&lt;placeholder&gt;']</code> array.<a href=".html"></a></p>
237<p>List of placeholders:</p>
238<ul>
239<li><code>buttons_toolbar</code>: after the list of buttons in the header.</li>
240</ul>
241<p><img src="http://i.imgur.com/ssJUOrt.png" alt="buttons_toolbar_example" /><a href=".html"></a></p>
242<ul>
243<li><code>fields_toolbar</code>: after search fields in the header.</li>
244</ul>
245<blockquote>
246<p>Note: This will only be called in linklist.</p>
247</blockquote>
248<p><img src="http://i.imgur.com/3GMifI2.png" alt="fields_toolbar_example" /><a href=".html"></a></p>
249<h4 id="render_includes">render_includes</h4>
250<p>Triggered on every page.</p>
251<p>Allow plugin to include their own CSS files.</p>
252<h5 id="data-1">Data</h5>
253<p><code>$data</code> is an array containing:</p>
254<ul>
255<li><code>_PAGE_</code>: current target page (eg: <code>linklist</code>, <code>picwall</code>, etc.).</li>
256<li><code>_LOGGEDIN_</code>: true if user is logged in, false otherwise.</li>
257</ul>
258<h5 id="template-placeholders-1">Template placeholders</h5>
259<p>Items can be displayed in templates by adding an entry in <code>$data['&lt;placeholder&gt;']</code> array.<a href=".html"></a></p>
260<p>List of placeholders:</p>
261<ul>
262<li><code>css_files</code>: called after loading default CSS.</li>
263</ul>
264<blockquote>
265<p>Note: only add the path of the CSS file. E.g: <code>plugins/demo_plugin/custom_demo.css</code>.</p>
266</blockquote>
267<h4 id="render_footer">render_footer</h4>
268<p>Triggered on every page.</p>
269<p>Allow plugin to add content in page footer and include their own JS files.</p>
270<h5 id="data-2">Data</h5>
271<p><code>$data</code> is an array containing:</p>
272<ul>
273<li><code>_PAGE_</code>: current target page (eg: <code>linklist</code>, <code>picwall</code>, etc.).</li>
274<li><code>_LOGGEDIN_</code>: true if user is logged in, false otherwise.</li>
275</ul>
276<h5 id="template-placeholders-2">Template placeholders</h5>
277<p>Items can be displayed in templates by adding an entry in <code>$data['&lt;placeholder&gt;']</code> array.<a href=".html"></a></p>
278<p>List of placeholders:</p>
279<ul>
280<li><code>text</code>: called after the end of the footer text.</li>
08dcd8ea 281<li><code>endofpage</code>: called at the end of the page.</li>
992af0b9
V
282</ul>
283<p><img src="http://i.imgur.com/L5S2YEH.png" alt="text_example" /><a href=".html"></a></p>
284<ul>
285<li><code>js_files</code>: called at the end of the page, to include custom JS scripts.</li>
286</ul>
287<blockquote>
288<p>Note: only add the path of the JS file. E.g: <code>plugins/demo_plugin/custom_demo.js</code>.</p>
289</blockquote>
290<h4 id="render_linklist">render_linklist</h4>
291<p>Triggered when <code>linklist</code> is displayed (list of links, permalink, search, tag filtered, etc.).</p>
292<p>It allows to add content at the begining and end of the page, after every link displayed and to alter link data.</p>
293<h5 id="data-3">Data</h5>
294<p><code>$data</code> is an array containing:</p>
295<ul>
296<li><code>_LOGGEDIN_</code>: true if user is logged in, false otherwise.</li>
297<li>All templates data, including links.</li>
298</ul>
299<h5 id="template-placeholders-3">Template placeholders</h5>
300<p>Items can be displayed in templates by adding an entry in <code>$data['&lt;placeholder&gt;']</code> array.<a href=".html"></a></p>
301<p>List of placeholders:</p>
302<ul>
303<li><code>action_plugin</code>: next to the button &quot;private only&quot; at the top and bottom of the page.</li>
304</ul>
305<p><img src="http://i.imgur.com/Q12PWg0.png" alt="action_plugin_example" /><a href=".html"></a></p>
306<ul>
307<li><code>link_plugin</code>: for every link, between permalink and link URL.</li>
308</ul>
309<p><img src="http://i.imgur.com/3oDPhWx.png" alt="link_plugin_example" /><a href=".html"></a></p>
310<ul>
311<li><code>plugin_start_zone</code>: before displaying the template content.</li>
312</ul>
313<p><img src="http://i.imgur.com/OVBkGy3.png" alt="plugin_start_zone_example" /><a href=".html"></a></p>
314<ul>
315<li><code>plugin_end_zone</code>: after displaying the template content.</li>
316</ul>
317<p><img src="http://i.imgur.com/6IoRuop.png" alt="plugin_end_zone_example" /><a href=".html"></a></p>
318<h4 id="render_editlink">render_editlink</h4>
319<p>Triggered when the link edition form is displayed.</p>
320<p>Allow to add fields in the form, or display elements.</p>
321<h5 id="data-4">Data</h5>
322<p><code>$data</code> is an array containing:</p>
323<ul>
324<li>All templates data.</li>
325</ul>
326<h5 id="template-placeholders-4">Template placeholders</h5>
327<p>Items can be displayed in templates by adding an entry in <code>$data['&lt;placeholder&gt;']</code> array.<a href=".html"></a></p>
328<p>List of placeholders:</p>
329<ul>
330<li><code>edit_link_plugin</code>: after tags field.</li>
331</ul>
332<p><img src="http://i.imgur.com/5u17Ens.png" alt="edit_link_plugin_example" /><a href=".html"></a></p>
333<h4 id="render_tools">render_tools</h4>
334<p>Triggered when the &quot;tools&quot; page is displayed.</p>
335<p>Allow to add content at the end of the page.</p>
336<h5 id="data-5">Data</h5>
337<p><code>$data</code> is an array containing:</p>
338<ul>
339<li>All templates data.</li>
340</ul>
341<h5 id="template-placeholders-5">Template placeholders</h5>
342<p>Items can be displayed in templates by adding an entry in <code>$data['&lt;placeholder&gt;']</code> array.<a href=".html"></a></p>
343<p>List of placeholders:</p>
344<ul>
345<li><code>tools_plugin</code>: at the end of the page.</li>
346</ul>
347<p><img src="http://i.imgur.com/Bqhu9oQ.png" alt="tools_plugin_example" /><a href=".html"></a></p>
348<h4 id="render_picwall">render_picwall</h4>
349<p>Triggered when picwall is displayed.</p>
350<p>Allow to add content at the top and bottom of the page.</p>
351<h5 id="data-6">Data</h5>
352<p><code>$data</code> is an array containing:</p>
353<ul>
354<li><code>_LOGGEDIN_</code>: true if user is logged in, false otherwise.</li>
355<li>All templates data.</li>
356</ul>
357<h5 id="template-placeholders-6">Template placeholders</h5>
358<p>Items can be displayed in templates by adding an entry in <code>$data['&lt;placeholder&gt;']</code> array.<a href=".html"></a></p>
359<p>List of placeholders:</p>
360<ul>
361<li><p><code>plugin_start_zone</code>: before displaying the template content.</p></li>
362<li><p><code>plugin_end_zone</code>: after displaying the template content.</p></li>
363</ul>
364<p><img src="http://i.imgur.com/tVTQFER.png" alt="plugin_start_end_zone_example" /><a href=".html"></a></p>
365<h4 id="render_tagcloud">render_tagcloud</h4>
366<p>Triggered when tagcloud is displayed.</p>
367<p>Allow to add content at the top and bottom of the page.</p>
368<h5 id="data-7">Data</h5>
369<p><code>$data</code> is an array containing:</p>
370<ul>
371<li><code>_LOGGEDIN_</code>: true if user is logged in, false otherwise.</li>
372<li>All templates data.</li>
373</ul>
374<h5 id="template-placeholders-7">Template placeholders</h5>
375<p>Items can be displayed in templates by adding an entry in <code>$data['&lt;placeholder&gt;']</code> array.<a href=".html"></a></p>
376<p>List of placeholders:</p>
377<ul>
378<li><p><code>plugin_start_zone</code>: before displaying the template content.</p></li>
379<li><p><code>plugin_end_zone</code>: after displaying the template content.</p></li>
380</ul>
381<p><img src="http://i.imgur.com/vHmyT3a.png" alt="plugin_start_end_zone_example" /><a href=".html"></a></p>
382<h4 id="render_daily">render_daily</h4>
383<p>Triggered when tagcloud is displayed.</p>
384<p>Allow to add content at the top and bottom of the page, the bottom of each link and to alter data.</p>
385<h5 id="data-8">Data</h5>
386<p><code>$data</code> is an array containing:</p>
387<ul>
388<li><code>_LOGGEDIN_</code>: true if user is logged in, false otherwise.</li>
389<li>All templates data, including links.</li>
390</ul>
391<h5 id="template-placeholders-8">Template placeholders</h5>
392<p>Items can be displayed in templates by adding an entry in <code>$data['&lt;placeholder&gt;']</code> array.<a href=".html"></a></p>
393<p>List of placeholders:</p>
394<ul>
395<li><code>link_plugin</code>: used at bottom of each link.</li>
396</ul>
397<p><img src="http://i.imgur.com/hzhMfSZ.png" alt="link_plugin_example" /><a href=".html"></a></p>
398<ul>
399<li><p><code>plugin_start_zone</code>: before displaying the template content.</p></li>
400<li><p><code>plugin_end_zone</code>: after displaying the template content.</p></li>
401</ul>
402<h4 id="savelink">savelink</h4>
403<p>Triggered when a link is save (new link or edit).</p>
404<p>Allow to alter the link being saved in the datastore.</p>
405<h5 id="data-9">Data</h5>
406<p><code>$data</code> is an array containing the link being saved:</p>
407<ul>
408<li>title</li>
409<li>url</li>
410<li>description</li>
411<li>linkdate</li>
412<li>private</li>
413<li>tags</li>
414</ul>
415<h2 id="guide-for-template-designer">Guide for template designer</h2>
5409ade2
A
416<h3 id="plugin-administration">Plugin administration</h3>
417<p>Your theme must include a plugin administration page: <code>pluginsadmin.html</code>.</p>
418<blockquote>
419<p>Note: repo's template link needs to be added when the PR is merged.</p>
420</blockquote>
421<p>Use the default one as an example.</p>
422<p>Aside from classic RainTPL loops, plugins order is handle by JavaScript. You can just include <code>plugin_admin.js</code>, only if:</p>
423<ul>
424<li>you're using a table.</li>
425<li>you call orderUp() and orderUp() onclick on arrows.</li>
426<li>you add data-line and data-order to your rows.</li>
427</ul>
428<p>Otherwise, you can use your own JS as long as this field is send by the form:</p>
429<p><input type="hidden" name="order_{$key}" value="{$counter}"></p>
992af0b9
V
430<h3 id="placeholder-system">Placeholder system</h3>
431<p>In order to make plugins work with every custom themes, you need to add variable placeholder in your templates.</p>
432<p>It's a RainTPL loop like this:</p>
433<pre><code>{loop=&quot;$plugin_variable&quot;}
434 {$value}
435{/loop}</code></pre>
436<p>You should enable <code>demo_plugin</code> for testing purpose, since it uses every placeholder available.</p>
437<h3 id="list-of-placeholders">List of placeholders</h3>
438<p><strong>page.header.html</strong></p>
439<p>At the end of the menu:</p>
440<pre><code>{loop=&quot;$plugins_header.buttons_toolbar&quot;}
441 {$value}
442{/loop}</code></pre>
5409ade2
A
443<p>At the end of file, before clearing floating blocks:</p>
444<pre><code>{if=&quot;!empty($plugin_errors) &amp;&amp; isLoggedIn()&quot;}
445 &lt;ul class=&quot;errors&quot;&gt;
446 {loop=&quot;plugin_errors&quot;}
447 &lt;li&gt;{$value}&lt;/li&gt;
448 {/loop}
449 &lt;/ul&gt;
450{/if}</code></pre>
992af0b9
V
451<p><strong>includes.html</strong></p>
452<p>At the end of the file:</p>
5409ade2 453<div class="sourceCode"><pre class="sourceCode html"><code class="sourceCode html">{loop=&quot;$plugins_includes.css_files&quot;}
992af0b9 454<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>
5409ade2 455{/loop}</code></pre></div>
992af0b9
V
456<p><strong>page.footer.html</strong></p>
457<p>At the end of your footer notes:</p>
5409ade2 458<div class="sourceCode"><pre class="sourceCode html"><code class="sourceCode html">{loop=&quot;$plugins_footer.text&quot;}
992af0b9 459 {$value}
5409ade2 460{/loop}</code></pre></div>
992af0b9 461<p>At the end of file:</p>
5409ade2 462<div class="sourceCode"><pre class="sourceCode html"><code class="sourceCode html">{loop=&quot;$plugins_footer.js_files&quot;}
992af0b9 463 <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>
5409ade2 464{/loop}</code></pre></div>
992af0b9
V
465<p><strong>linklist.html</strong></p>
466<p>After search fields:</p>
5409ade2 467<div class="sourceCode"><pre class="sourceCode html"><code class="sourceCode html">{loop=&quot;$plugins_header.fields_toolbar&quot;}
992af0b9 468 {$value}
5409ade2 469{/loop}</code></pre></div>
992af0b9 470<p>Before displaying the link list (after paging):</p>
5409ade2 471<div class="sourceCode"><pre class="sourceCode html"><code class="sourceCode html">{loop=&quot;$plugin_start_zone&quot;}
992af0b9 472 {$value}
5409ade2 473{/loop}</code></pre></div>
992af0b9 474<p>For every links (icons):</p>
5409ade2 475<div class="sourceCode"><pre class="sourceCode html"><code class="sourceCode html">{loop=&quot;$value.link_plugin&quot;}
992af0b9 476 <span class="kw">&lt;span&gt;</span>{$value}<span class="kw">&lt;/span&gt;</span>
5409ade2 477{/loop}</code></pre></div>
992af0b9 478<p>Before end paging:</p>
5409ade2 479<div class="sourceCode"><pre class="sourceCode html"><code class="sourceCode html">{loop=&quot;$plugin_end_zone&quot;}
992af0b9 480 {$value}
5409ade2 481{/loop}</code></pre></div>
992af0b9
V
482<p><strong>linklist.paging.html</strong></p>
483<p>After the &quot;private only&quot; icon:</p>
5409ade2 484<div class="sourceCode"><pre class="sourceCode html"><code class="sourceCode html">{loop=&quot;$action_plugin&quot;}
992af0b9 485 {$value}
5409ade2 486{/loop}</code></pre></div>
992af0b9
V
487<p><strong>editlink.html</strong></p>
488<p>After tags field:</p>
5409ade2 489<div class="sourceCode"><pre class="sourceCode html"><code class="sourceCode html">{loop=&quot;$edit_link_plugin&quot;}
992af0b9 490 {$value}
5409ade2 491{/loop}</code></pre></div>
992af0b9
V
492<p><strong>tools.html</strong></p>
493<p>After the last tool:</p>
5409ade2 494<div class="sourceCode"><pre class="sourceCode html"><code class="sourceCode html">{loop=&quot;$tools_plugin&quot;}
992af0b9 495 {$value}
5409ade2 496{/loop}</code></pre></div>
992af0b9
V
497<p><strong>picwall.html</strong></p>
498<p>Top:</p>
5409ade2 499<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>
992af0b9
V
500 {loop=&quot;$plugin_start_zone&quot;}
501 {$value}
502 {/loop}
5409ade2 503<span class="kw">&lt;/div&gt;</span></code></pre></div>
992af0b9 504<p>Bottom:</p>
5409ade2 505<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>
992af0b9
V
506 {loop=&quot;$plugin_end_zone&quot;}
507 {$value}
508 {/loop}
5409ade2 509<span class="kw">&lt;/div&gt;</span></code></pre></div>
992af0b9
V
510<p><strong>tagcloud.html</strong></p>
511<p>Top:</p>
5409ade2 512<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>
992af0b9
V
513 {loop=&quot;$plugin_start_zone&quot;}
514 {$value}
515 {/loop}
5409ade2 516 <span class="kw">&lt;/div&gt;</span></code></pre></div>
992af0b9 517<p>Bottom:</p>
5409ade2 518<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>
992af0b9
V
519 {loop=&quot;$plugin_end_zone&quot;}
520 {$value}
521 {/loop}
5409ade2 522 <span class="kw">&lt;/div&gt;</span></code></pre></div>
992af0b9
V
523<p><strong>daily.html</strong></p>
524<p>Top:</p>
5409ade2 525<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>
992af0b9
V
526 {loop=&quot;$plugin_start_zone&quot;}
527 {$value}
528 {/loop}
5409ade2 529<span class="kw">&lt;/div&gt;</span></code></pre></div>
992af0b9 530<p>After every link:</p>
5409ade2 531<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>
992af0b9
V
532 {loop=&quot;$link.link_plugin&quot;}
533 {$value}
534 {/loop}
5409ade2 535<span class="kw">&lt;/div&gt;</span></code></pre></div>
992af0b9 536<p>Bottom:</p>
5409ade2 537<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>
992af0b9
V
538 {loop=&quot;$plugin_end_zone&quot;}
539 {$value}
540 {/loop}
5409ade2 541<span class="kw">&lt;/div&gt;</span></code></pre></div>
992af0b9
V
542</body>
543</html>