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