]>
Commit | Line | Data |
---|---|---|
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"> | |
10 | div.sourceCode { overflow-x: auto; } | |
11 | table.sourceCode, tr.sourceCode, td.lineNumbers, td.sourceCode { | |
12 | margin: 0; padding: 0; vertical-align: baseline; border: none; } | |
13 | table.sourceCode { width: 100%; line-height: 100%; } | |
14 | td.lineNumbers { text-align: right; padding-right: 4px; padding-left: 4px; color: #aaaaaa; border-right: 1px solid #aaaaaa; } | |
15 | td.sourceCode { padding-left: 5px; } | |
16 | code > span.kw { color: #007020; font-weight: bold; } /* Keyword */ | |
17 | code > span.dt { color: #902000; } /* DataType */ | |
18 | code > span.dv { color: #40a070; } /* DecVal */ | |
19 | code > span.bn { color: #40a070; } /* BaseN */ | |
20 | code > span.fl { color: #40a070; } /* Float */ | |
21 | code > span.ch { color: #4070a0; } /* Char */ | |
22 | code > span.st { color: #4070a0; } /* String */ | |
23 | code > span.co { color: #60a0b0; font-style: italic; } /* Comment */ | |
24 | code > span.ot { color: #007020; } /* Other */ | |
25 | code > span.al { color: #ff0000; font-weight: bold; } /* Alert */ | |
26 | code > span.fu { color: #06287e; } /* Function */ | |
27 | code > span.er { color: #ff0000; font-weight: bold; } /* Error */ | |
28 | code > span.wa { color: #60a0b0; font-weight: bold; font-style: italic; } /* Warning */ | |
29 | code > span.cn { color: #880000; } /* Constant */ | |
30 | code > span.sc { color: #4070a0; } /* SpecialChar */ | |
31 | code > span.vs { color: #4070a0; } /* VerbatimString */ | |
32 | code > span.ss { color: #bb6688; } /* SpecialString */ | |
33 | code > span.im { } /* Import */ | |
34 | code > span.va { color: #19177c; } /* Variable */ | |
35 | code > span.cf { color: #007020; font-weight: bold; } /* ControlFlow */ | |
36 | code > span.op { color: #666666; } /* Operator */ | |
37 | code > span.bu { } /* BuiltIn */ | |
38 | code > span.ex { } /* Extension */ | |
39 | code > span.pp { color: #bc7a00; } /* Preprocessor */ | |
40 | code > span.at { color: #7d9029; } /* Attribute */ | |
41 | code > span.do { color: #ba2121; font-style: italic; } /* Documentation */ | |
42 | code > span.an { color: #60a0b0; font-weight: bold; font-style: italic; } /* Annotation */ | |
43 | code > span.cv { color: #60a0b0; font-weight: bold; font-style: italic; } /* CommentVar */ | |
44 | code > 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>Installation | |
56 | <ul> | |
57 | <li><a href="Download.html">Download</a></li> | |
58 | <li><a href="Server-requirements.html">Server requirements</a></li> | |
59 | <li><a href="Server-configuration.html">Server configuration</a></li> | |
60 | <li><a href="Server-security.html">Server security</a></li> | |
61 | <li><a href="Shaarli-installation.html">Shaarli installation</a></li> | |
62 | <li><a href="Shaarli-configuration.html">Shaarli configuration</a></li> | |
63 | <li><a href="Plugin-installation-&-configuration.html">Plugin installation & configuration</a></li> | |
64 | </ul></li> | |
65 | <li><a href="Docker.html">Docker</a></li> | |
66 | <li><a href="Plugin-list.html">Plugin list</a></li> | |
67 | <li><a href="Usage.html">Usage</a> | |
68 | <ul> | |
69 | <li><a href="Sharing-button.html">Sharing button</a> (bookmarklet)</li> | |
70 | <li><a href="Browsing-and-Searching.html">Browsing and Searching</a></li> | |
71 | <li><a href="Firefox-share.html">Firefox share</a></li> | |
72 | <li><a href="RSS-feeds.html">RSS feeds</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="Upgrade-from-original-sebsauvage/Shaarli.html">Upgrade from original sebsauvage/Shaarli</a></li> | |
78 | <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> | |
79 | <li><a href="Create-and-serve-multiple-Shaarlis-(farm).html">Create and serve multiple Shaarlis (farm)</a></li> | |
80 | <li><a href="Download-CSS-styles-from-an-OPML-list.html">Download CSS styles from an OPML list</a></li> | |
81 | <li><a href="Datastore-hacks.html">Datastore hacks</a></li> | |
82 | </ul></li> | |
83 | <li><a href="Troubleshooting.html">Troubleshooting</a></li> | |
84 | <li><a href="Development.html">Development</a> | |
85 | <ul> | |
86 | <li><a href="GnuPG-signature.html">GnuPG signature</a></li> | |
87 | <li><a href="Coding-guidelines.html">Coding guidelines</a></li> | |
88 | <li><a href="Directory-structure.html">Directory structure</a></li> | |
89 | <li><a href="3rd-party-libraries.html">3rd party libraries</a></li> | |
90 | <li><a href="Plugin-System.html">Plugin System</a></li> | |
91 | <li><a href="Release-Shaarli.html">Release Shaarli</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-&-Related-software.html">Community & Related software</a></li> | |
101 | <li><a href="TODO.html">TODO</a></li> | |
102 | </ul></li> | |
103 | </ul> | |
104 | </div> | |
105 | <h1 id="plugin-system">Plugin System</h1> | |
106 | <blockquote> | |
107 | <p>Note: Plugin current status - in development (not merged into master).</p> | |
108 | </blockquote> | |
109 | <p><a href="#developer-api"><strong>I am a developer.</strong> Developer API.</a><a href=".html"></a></p> | |
110 | <p><a href="#guide-for-template-designer"><strong>I am a template designer.</strong> Guide for template designer.</a><a href=".html"></a></p> | |
111 | <h2 id="developer-api">Developer API</h2> | |
112 | <h3 id="what-can-i-do-with-plugins">What can I do with plugins?</h3> | |
113 | <p>The plugin system let you:</p> | |
114 | <ul> | |
115 | <li>insert content into specific places across templates.</li> | |
116 | <li>alter data before templates rendering.</li> | |
117 | <li>alter data before saving new links.</li> | |
118 | </ul> | |
119 | <h3 id="how-can-i-create-a-plugin-for-shaarli">How can I create a plugin for Shaarli?</h3> | |
120 | <p>First, chose a plugin name, such as <code>demo_plugin</code>.</p> | |
121 | <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> | |
122 | <p>You should have the following tree view:</p> | |
123 | <pre><code>| index.php | |
124 | | plugins/ | |
125 | |---| demo_plugin/ | |
126 | | |---| demo_plugin.php</code></pre> | |
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_<plugin_name>_<hook_name></code></pre> | |
131 | <p>For exemple, if my plugin want to add data to the header, this function is needed:</p> | |
132 | <pre><code>hook_demo_plugin_render_header()</code></pre> | |
133 | <p>If this function is declared, and the plugin enabled, it will be called every time Shaarli is rendering the header.</p> | |
134 | <h3 id="plugins-data">Plugin's data</h3> | |
135 | <h4 id="parameters">Parameters</h4> | |
136 | <p>Every hook function has a <code>$data</code> parameter. Its content differs for each hooks.</p> | |
137 | <p><strong>This parameter needs to be returned every time</strong>, otherwise data is lost.</p> | |
138 | <pre><code>return $data;</code></pre> | |
139 | <h4 id="filling-templates-placeholder">Filling templates placeholder</h4> | |
140 | <p>Template placeholders are displayed in template in specific places.</p> | |
141 | <p>RainTPL displays every element contained in the placeholder's array. These element can be added by plugins.</p> | |
142 | <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> | |
143 | <div class="sourceCode"><pre class="sourceCode php"><code class="sourceCode php"><span class="kw">$data</span><span class="ot">[</span><span class="st">'top_placeholder'</span><span class="ot">[]</span> = <span class="st">'My content'</span><span class="ot">;](]</span>-=-<span class="st">'My-content'</span><span class="ot">;</span>.html<span class="ot">)</span> | |
144 | <span class="co"># OR</span> | |
145 | <span class="fu">array_push</span><span class="ot">(</span><span class="kw">$data</span><span class="ot">[</span><span class="st">'top_placeholder'</span><span class="ot">],</span> <span class="st">'My'</span><span class="ot">,</span> <span class="st">'content'</span><span class="ot">);[](</span>.html<span class="ot">)</span> | |
146 | ||
147 | <span class="kw">return</span> <span class="kw">$data</span><span class="ot">;</span></code></pre></div> | |
148 | <h4 id="data-manipulation">Data manipulation</h4> | |
149 | <p>When a page is displayed, every variable send to the template engine is passed to plugins before that in <code>$data</code>.</p> | |
150 | <p>The data contained by this array can be altered before template rendering.</p> | |
151 | <p>For exemple, in linklist, it is possible to alter every title:</p> | |
152 | <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> | |
153 | <span class="kw">foreach</span> <span class="ot">(</span><span class="kw">$data</span><span class="ot">[</span><span class="st">'links'</span><span class="ot">]</span> <span class="kw">as</span> &<span class="kw">$value</span><span class="ot">)</span> {<span class="ot">[](</span>.html<span class="ot">)</span> | |
154 | <span class="co">// String reverse every title.</span> | |
155 | <span class="kw">$value</span><span class="ot">[</span><span class="st">'title'</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">'title'</span><span class="ot">]);[](</span>.html<span class="ot">)</span> | |
156 | } | |
157 | ||
158 | <span class="kw">return</span> <span class="kw">$data</span><span class="ot">;</span></code></pre></div> | |
159 | <h3 id="metadata">Metadata</h3> | |
160 | <p>Every plugin needs a <code><plugin_name>.meta</code> file, which is in fact an <code>.ini</code> file (<code>KEY="VALUE"</code>), to be listed in plugin administration.</p> | |
161 | <p>Each file contain two keys:</p> | |
162 | <ul> | |
163 | <li><code>description</code>: plugin description</li> | |
164 | <li><code>parameters</code>: user parameter names, separated by a <code>;</code>.</li> | |
165 | </ul> | |
166 | <blockquote> | |
167 | <p>Note: In PHP, <code>parse_ini_file()</code> seems to want strings to be between by quotes <code>"</code> in the ini file.</p> | |
168 | </blockquote> | |
169 | <h3 id="its-not-working">It's not working!</h3> | |
170 | <p>Use <code>demo_plugin</code> as a functional example. It covers most of the plugin system features.</p> | |
171 | <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> | |
172 | <h3 id="hooks">Hooks</h3> | |
173 | <table style="width:42%;"> | |
174 | <colgroup> | |
175 | <col style="width: 19%" /> | |
176 | <col style="width: 22%" /> | |
177 | </colgroup> | |
178 | <thead> | |
179 | <tr class="header"> | |
180 | <th>Hooks</th> | |
181 | <th style="text-align: center;">Description</th> | |
182 | </tr> | |
183 | </thead> | |
184 | <tbody> | |
185 | <tr class="odd"> | |
186 | <td><a href="#render_header">render_header</a></td> | |
187 | <td style="text-align: center;">Allow plugin to add content in page headers.</td> | |
188 | </tr> | |
189 | <tr class="even"> | |
190 | <td><a href="#render_includes">render_includes</a></td> | |
191 | <td style="text-align: center;">Allow plugin to include their own CSS files.</td> | |
192 | </tr> | |
193 | <tr class="odd"> | |
194 | <td><a href="#render_footer">render_footer</a></td> | |
195 | <td style="text-align: center;">Allow plugin to add content in page footer and include their own JS files.</td> | |
196 | </tr> | |
197 | <tr class="even"> | |
198 | <td><a href="#render_linklist">render_linklist</a></td> | |
199 | <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> | |
200 | </tr> | |
201 | <tr class="odd"> | |
202 | <td><a href="#render_editlink">render_editlink</a></td> | |
203 | <td style="text-align: center;">Allow to add fields in the form, or display elements.</td> | |
204 | </tr> | |
205 | <tr class="even"> | |
206 | <td><a href="#render_tools">render_tools</a></td> | |
207 | <td style="text-align: center;">Allow to add content at the end of the page.</td> | |
208 | </tr> | |
209 | <tr class="odd"> | |
210 | <td><a href="#render_picwall">render_picwall</a></td> | |
211 | <td style="text-align: center;">Allow to add content at the top and bottom of the page.</td> | |
212 | </tr> | |
213 | <tr class="even"> | |
214 | <td><a href="#render_tagcloud">render_tagcloud</a></td> | |
215 | <td style="text-align: center;">Allow to add content at the top and bottom of the page.</td> | |
216 | </tr> | |
217 | <tr class="odd"> | |
218 | <td><a href="#render_daily">render_daily</a></td> | |
219 | <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> | |
220 | </tr> | |
221 | <tr class="even"> | |
222 | <td><a href="#savelink">savelink</a></td> | |
223 | <td style="text-align: center;">Allow to alter the link being saved in the datastore.</td> | |
224 | </tr> | |
225 | </tbody> | |
226 | </table> | |
227 | <h4 id="render_header">render_header</h4> | |
228 | <p>Triggered on every page.</p> | |
229 | <p>Allow plugin to add content in page headers.</p> | |
230 | <h5 id="data">Data</h5> | |
231 | <p><code>$data</code> is an array containing:</p> | |
232 | <ul> | |
233 | <li><code>_PAGE_</code>: current target page (eg: <code>linklist</code>, <code>picwall</code>, etc.).</li> | |
234 | <li><code>_LOGGEDIN_</code>: true if user is logged in, false otherwise.</li> | |
235 | </ul> | |
236 | <h5 id="template-placeholders">Template placeholders</h5> | |
237 | <p>Items can be displayed in templates by adding an entry in <code>$data['<placeholder>']</code> array.<a href=".html"></a></p> | |
238 | <p>List of placeholders:</p> | |
239 | <ul> | |
240 | <li><code>buttons_toolbar</code>: after the list of buttons in the header.</li> | |
241 | </ul> | |
242 | <p><img src="http://i.imgur.com/ssJUOrt.png" alt="buttons_toolbar_example" /><a href=".html"></a></p> | |
243 | <ul> | |
244 | <li><code>fields_toolbar</code>: after search fields in the header.</li> | |
245 | </ul> | |
246 | <blockquote> | |
247 | <p>Note: This will only be called in linklist.</p> | |
248 | </blockquote> | |
249 | <p><img src="http://i.imgur.com/3GMifI2.png" alt="fields_toolbar_example" /><a href=".html"></a></p> | |
250 | <h4 id="render_includes">render_includes</h4> | |
251 | <p>Triggered on every page.</p> | |
252 | <p>Allow plugin to include their own CSS files.</p> | |
253 | <h5 id="data-1">Data</h5> | |
254 | <p><code>$data</code> is an array containing:</p> | |
255 | <ul> | |
256 | <li><code>_PAGE_</code>: current target page (eg: <code>linklist</code>, <code>picwall</code>, etc.).</li> | |
257 | <li><code>_LOGGEDIN_</code>: true if user is logged in, false otherwise.</li> | |
258 | </ul> | |
259 | <h5 id="template-placeholders-1">Template placeholders</h5> | |
260 | <p>Items can be displayed in templates by adding an entry in <code>$data['<placeholder>']</code> array.<a href=".html"></a></p> | |
261 | <p>List of placeholders:</p> | |
262 | <ul> | |
263 | <li><code>css_files</code>: called after loading default CSS.</li> | |
264 | </ul> | |
265 | <blockquote> | |
266 | <p>Note: only add the path of the CSS file. E.g: <code>plugins/demo_plugin/custom_demo.css</code>.</p> | |
267 | </blockquote> | |
268 | <h4 id="render_footer">render_footer</h4> | |
269 | <p>Triggered on every page.</p> | |
270 | <p>Allow plugin to add content in page footer and include their own JS files.</p> | |
271 | <h5 id="data-2">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-2">Template placeholders</h5> | |
278 | <p>Items can be displayed in templates by adding an entry in <code>$data['<placeholder>']</code> array.<a href=".html"></a></p> | |
279 | <p>List of placeholders:</p> | |
280 | <ul> | |
281 | <li><code>text</code>: called after the end of the footer text.</li> | |
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['<placeholder>']</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 "private only" 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['<placeholder>']</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 "tools" 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['<placeholder>']</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['<placeholder>']</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['<placeholder>']</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['<placeholder>']</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> | |
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> | |
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="$plugin_variable"} | |
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="$plugins_header.buttons_toolbar"} | |
441 | {$value} | |
442 | {/loop}</code></pre> | |
443 | <p>At the end of file, before clearing floating blocks:</p> | |
444 | <pre><code>{if="!empty($plugin_errors) && isLoggedIn()"} | |
445 | <ul class="errors"> | |
446 | {loop="plugin_errors"} | |
447 | <li>{$value}</li> | |
448 | {/loop} | |
449 | </ul> | |
450 | {/if}</code></pre> | |
451 | <p><strong>includes.html</strong></p> | |
452 | <p>At the end of the file:</p> | |
453 | <div class="sourceCode"><pre class="sourceCode html"><code class="sourceCode html">{loop="$plugins_includes.css_files"} | |
454 | <span class="kw"><link</span><span class="ot"> type=</span><span class="st">"text/css"</span><span class="ot"> rel=</span><span class="st">"stylesheet"</span><span class="ot"> href=</span><span class="st">"{$value}#"</span><span class="kw">/></span> | |
455 | {/loop}</code></pre></div> | |
456 | <p><strong>page.footer.html</strong></p> | |
457 | <p>At the end of your footer notes:</p> | |
458 | <div class="sourceCode"><pre class="sourceCode html"><code class="sourceCode html">{loop="$plugins_footer.text"} | |
459 | {$value} | |
460 | {/loop}</code></pre></div> | |
461 | <p>At the end of file:</p> | |
462 | <div class="sourceCode"><pre class="sourceCode html"><code class="sourceCode html">{loop="$plugins_footer.js_files"} | |
463 | <span class="kw"><script</span><span class="ot"> src=</span><span class="st">"{$value}#"</span><span class="kw">></script></span> | |
464 | {/loop}</code></pre></div> | |
465 | <p><strong>linklist.html</strong></p> | |
466 | <p>After search fields:</p> | |
467 | <div class="sourceCode"><pre class="sourceCode html"><code class="sourceCode html">{loop="$plugins_header.fields_toolbar"} | |
468 | {$value} | |
469 | {/loop}</code></pre></div> | |
470 | <p>Before displaying the link list (after paging):</p> | |
471 | <div class="sourceCode"><pre class="sourceCode html"><code class="sourceCode html">{loop="$plugin_start_zone"} | |
472 | {$value} | |
473 | {/loop}</code></pre></div> | |
474 | <p>For every links (icons):</p> | |
475 | <div class="sourceCode"><pre class="sourceCode html"><code class="sourceCode html">{loop="$value.link_plugin"} | |
476 | <span class="kw"><span></span>{$value}<span class="kw"></span></span> | |
477 | {/loop}</code></pre></div> | |
478 | <p>Before end paging:</p> | |
479 | <div class="sourceCode"><pre class="sourceCode html"><code class="sourceCode html">{loop="$plugin_end_zone"} | |
480 | {$value} | |
481 | {/loop}</code></pre></div> | |
482 | <p><strong>linklist.paging.html</strong></p> | |
483 | <p>After the "private only" icon:</p> | |
484 | <div class="sourceCode"><pre class="sourceCode html"><code class="sourceCode html">{loop="$action_plugin"} | |
485 | {$value} | |
486 | {/loop}</code></pre></div> | |
487 | <p><strong>editlink.html</strong></p> | |
488 | <p>After tags field:</p> | |
489 | <div class="sourceCode"><pre class="sourceCode html"><code class="sourceCode html">{loop="$edit_link_plugin"} | |
490 | {$value} | |
491 | {/loop}</code></pre></div> | |
492 | <p><strong>tools.html</strong></p> | |
493 | <p>After the last tool:</p> | |
494 | <div class="sourceCode"><pre class="sourceCode html"><code class="sourceCode html">{loop="$tools_plugin"} | |
495 | {$value} | |
496 | {/loop}</code></pre></div> | |
497 | <p><strong>picwall.html</strong></p> | |
498 | <p>Top:</p> | |
499 | <div class="sourceCode"><pre class="sourceCode html"><code class="sourceCode html"><span class="kw"><div</span><span class="ot"> id=</span><span class="st">"plugin_zone_start_picwall"</span><span class="ot"> class=</span><span class="st">"plugin_zone"</span><span class="kw">></span> | |
500 | {loop="$plugin_start_zone"} | |
501 | {$value} | |
502 | {/loop} | |
503 | <span class="kw"></div></span></code></pre></div> | |
504 | <p>Bottom:</p> | |
505 | <div class="sourceCode"><pre class="sourceCode html"><code class="sourceCode html"><span class="kw"><div</span><span class="ot"> id=</span><span class="st">"plugin_zone_end_picwall"</span><span class="ot"> class=</span><span class="st">"plugin_zone"</span><span class="kw">></span> | |
506 | {loop="$plugin_end_zone"} | |
507 | {$value} | |
508 | {/loop} | |
509 | <span class="kw"></div></span></code></pre></div> | |
510 | <p><strong>tagcloud.html</strong></p> | |
511 | <p>Top:</p> | |
512 | <div class="sourceCode"><pre class="sourceCode html"><code class="sourceCode html"> <span class="kw"><div</span><span class="ot"> id=</span><span class="st">"plugin_zone_start_tagcloud"</span><span class="ot"> class=</span><span class="st">"plugin_zone"</span><span class="kw">></span> | |
513 | {loop="$plugin_start_zone"} | |
514 | {$value} | |
515 | {/loop} | |
516 | <span class="kw"></div></span></code></pre></div> | |
517 | <p>Bottom:</p> | |
518 | <div class="sourceCode"><pre class="sourceCode html"><code class="sourceCode html"> <span class="kw"><div</span><span class="ot"> id=</span><span class="st">"plugin_zone_end_tagcloud"</span><span class="ot"> class=</span><span class="st">"plugin_zone"</span><span class="kw">></span> | |
519 | {loop="$plugin_end_zone"} | |
520 | {$value} | |
521 | {/loop} | |
522 | <span class="kw"></div></span></code></pre></div> | |
523 | <p><strong>daily.html</strong></p> | |
524 | <p>Top:</p> | |
525 | <div class="sourceCode"><pre class="sourceCode html"><code class="sourceCode html"><span class="kw"><div</span><span class="ot"> id=</span><span class="st">"plugin_zone_start_picwall"</span><span class="ot"> class=</span><span class="st">"plugin_zone"</span><span class="kw">></span> | |
526 | {loop="$plugin_start_zone"} | |
527 | {$value} | |
528 | {/loop} | |
529 | <span class="kw"></div></span></code></pre></div> | |
530 | <p>After every link:</p> | |
531 | <div class="sourceCode"><pre class="sourceCode html"><code class="sourceCode html"><span class="kw"><div</span><span class="ot"> class=</span><span class="st">"dailyEntryFooter"</span><span class="kw">></span> | |
532 | {loop="$link.link_plugin"} | |
533 | {$value} | |
534 | {/loop} | |
535 | <span class="kw"></div></span></code></pre></div> | |
536 | <p>Bottom:</p> | |
537 | <div class="sourceCode"><pre class="sourceCode html"><code class="sourceCode html"><span class="kw"><div</span><span class="ot"> id=</span><span class="st">"plugin_zone_end_picwall"</span><span class="ot"> class=</span><span class="st">"plugin_zone"</span><span class="kw">></span> | |
538 | {loop="$plugin_end_zone"} | |
539 | {$value} | |
540 | {/loop} | |
541 | <span class="kw"></div></span></code></pre></div> | |
542 | </body> | |
543 | </html> |