]>
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 | <!--[if lt IE 9]> | |
10 | <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script> | |
11 | <![endif]--> | |
12 | <style type="text/css"> | |
13 | table.sourceCode, tr.sourceCode, td.lineNumbers, td.sourceCode { | |
14 | margin: 0; padding: 0; vertical-align: baseline; border: none; } | |
15 | table.sourceCode { width: 100%; line-height: 100%; } | |
16 | td.lineNumbers { text-align: right; padding-right: 4px; padding-left: 4px; color: #aaaaaa; border-right: 1px solid #aaaaaa; } | |
17 | td.sourceCode { padding-left: 5px; } | |
18 | code > span.kw { color: #007020; font-weight: bold; } | |
19 | code > span.dt { color: #902000; } | |
20 | code > span.dv { color: #40a070; } | |
21 | code > span.bn { color: #40a070; } | |
22 | code > span.fl { color: #40a070; } | |
23 | code > span.ch { color: #4070a0; } | |
24 | code > span.st { color: #4070a0; } | |
25 | code > span.co { color: #60a0b0; font-style: italic; } | |
26 | code > span.ot { color: #007020; } | |
27 | code > span.al { color: #ff0000; font-weight: bold; } | |
28 | code > span.fu { color: #06287e; } | |
29 | code > span.er { color: #ff0000; font-weight: bold; } | |
30 | </style> | |
31 | <link rel="stylesheet" href="github-markdown.css"> | |
32 | </head> | |
33 | <body> | |
34 | <div id="local-sidebar"> | |
35 | <ul> | |
36 | <li><a href="Home.html">Home</a></li> | |
37 | <li>Installation | |
38 | <ul> | |
39 | <li><a href="Download.html">Download</a></li> | |
40 | <li><a href="Server-requirements.html">Server requirements</a></li> | |
41 | <li><a href="Server-configuration.html">Server configuration</a></li> | |
42 | <li><a href="Shaarli-configuration.html">Shaarli configuration</a></li> | |
43 | </ul></li> | |
44 | <li><a href="Usage.html">Usage</a> | |
45 | <ul> | |
46 | <li><a href="Sharing-button.html">Sharing button</a> (bookmarklet)</li> | |
47 | <li><a href="Firefox-share.html">Firefox share</a></li> | |
48 | <li><a href="RSS-feeds.html">RSS feeds</a></li> | |
49 | </ul></li> | |
50 | <li>How To | |
51 | <ul> | |
52 | <li><a href="Backup,-restore,-import-and-export.html">Backup, restore, import and export</a></li> | |
53 | <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> | |
54 | <li><a href="Download-CSS-styles-from-an-OPML-list.html">Download CSS styles from an OPML list</a></li> | |
55 | <li><a href="Datastore-hacks.html">Datastore hacks</a></li> | |
56 | </ul></li> | |
57 | <li><a href="Troubleshooting.html">Troubleshooting</a></li> | |
58 | <li><a href="Development.html">Development</a> | |
59 | <ul> | |
60 | <li><a href="GnuPG-signature.html">GnuPG signature</a></li> | |
61 | <li><a href="Coding-guidelines.html">Coding guidelines</a></li> | |
62 | <li><a href="Directory-structure.html">Directory structure</a></li> | |
63 | <li><a href="3rd-party-libraries.html">3rd party libraries</a></li> | |
64 | <li><a href="Plugin-System.html">Plugin System</a></li> | |
65 | <li><a href="Security.html">Security</a></li> | |
66 | <li><a href="Static-analysis.html">Static analysis</a></li> | |
67 | <li><a href="Theming.html">Theming</a></li> | |
68 | <li><a href="Unit-tests.html">Unit tests</a></li> | |
69 | </ul></li> | |
70 | <li>About | |
71 | <ul> | |
72 | <li><a href="FAQ.html">FAQ</a></li> | |
73 | <li><a href="Community-&-Related-software.html">Community & Related software</a></li> | |
74 | <li><a href="TODO.html">TODO</a></li> | |
75 | </ul></li> | |
76 | </ul> | |
77 | </div> | |
78 | <h1 id="plugin-system">Plugin System</h1> | |
79 | <blockquote> | |
80 | <p>Note: Plugin current status - in developpement (not merged into master).</p> | |
81 | </blockquote> | |
82 | <p><a href="#plugin-user-guide"><strong>I am a user.</strong> Plugin User Guide.</a><a href=".html"></a></p> | |
83 | <p><a href="#developper-api"><strong>I am a developper.</strong> Developper API.</a><a href=".html"></a></p> | |
84 | <p><a href="#guide-for-template-designer"><strong>I am a template designer.</strong> Guide for template designer.</a><a href=".html"></a></p> | |
85 | <h2 id="plugin-user-guide">Plugin User Guide</h2> | |
86 | <h3 id="manage-plugins">Manage plugins</h3> | |
87 | <p>In <code>config.php</code>, change $GLOBALS<a href="'ENABLED_PLUGINS']-array:.html">'config'['ENABLED_PLUGINS'] array:</a></p> | |
88 | <pre class="sourceCode php"><code class="sourceCode php"><span class="kw">$GLOBALS</span><span class="ot">[</span><span class="st">'config'</span><span class="ot">[</span><span class="st">'ENABLED_PLUGINS'</span><span class="ot">]](</span><span class="st">'ENABLED_PLUGINS'</span><span class="ot">]</span>.html<span class="ot">)</span></code></pre> | |
89 | <p>Full list:</p> | |
90 | <pre class="sourceCode php"><code class="sourceCode php"><span class="kw">$GLOBALS</span><span class="ot">[</span><span class="st">'config'</span><span class="ot">[</span><span class="st">'ENABLED_PLUGINS'</span><span class="ot">]</span> = <span class="fu">array</span><span class="ot">(](</span><span class="st">'ENABLED_PLUGINS'</span><span class="ot">]</span>-=-<span class="fu">array</span><span class="ot">(</span>.html<span class="ot">)</span> | |
91 | <span class="st">'qrcode'</span><span class="ot">,</span> <span class="st">'archiveorg'</span><span class="ot">,</span> <span class="st">'readityourself'</span><span class="ot">,</span> <span class="st">'playvideos'</span><span class="ot">,</span> | |
92 | <span class="st">'wallabag'</span><span class="ot">,</span> <span class="st">'markdown'</span><span class="ot">,</span> <span class="st">'addlink_toolbar'</span><span class="ot">,</span> | |
93 | <span class="ot">);</span></code></pre> | |
94 | <h3 id="list-of-plugins">List of plugins</h3> | |
95 | <p>Plugin maintained by the community:</p> | |
96 | <ul> | |
97 | <li>Archive.org - add a clickable icon to every link to archive.org.</li> | |
98 | <li>Addlink in toolbar - add a field to paste new links URL in toolbar.</li> | |
99 | <li>Markdown - write and display Shaare in Markdown.</li> | |
100 | <li>Play videos - popup to play all videos displayed in linklist.</li> | |
101 | <li>QRCode - add a clickable icon generating a QRCode for every link.</li> | |
102 | <li>ReadItYourself - add a clickable icon for ReadItYourself.</li> | |
103 | <li>Wallabag - add a clickable icon for Wallabag.</li> | |
104 | </ul> | |
105 | <h2 id="developper-api">Developper API</h2> | |
106 | <h3 id="what-can-i-do-with-plugins">What can I do with plugins?</h3> | |
107 | <p>The plugin system let you:</p> | |
108 | <ul> | |
109 | <li>insert content into specific places across templates.</li> | |
110 | <li>alter data before templates rendering.</li> | |
111 | <li>alter data before saving new links.</li> | |
112 | </ul> | |
113 | <h3 id="how-can-i-create-a-plugin-for-shaarli">How can I create a plugin for Shaarli?</h3> | |
114 | <p>First, chose a plugin name, such as <code>demo_plugin</code>.</p> | |
115 | <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> | |
116 | <p>You should have the following tree view:</p> | |
117 | <pre><code>| index.php | |
118 | | plugins/ | |
119 | |---| demo_plugin/ | |
120 | | |---| demo_plugin.php</code></pre> | |
121 | <h3 id="understanding-hooks">Understanding hooks</h3> | |
122 | <p>A plugin is a set of functions. Each function will be triggered by the plugin system at certain point in Shaarli execution.</p> | |
123 | <p>These functions need to be named with this pattern:</p> | |
124 | <pre><code>hook_<plugin_name>_<hook_name></code></pre> | |
125 | <p>For exemple, if my plugin want to add data to the header, this function is needed:</p> | |
126 | <pre><code>hook_demo_plugin_render_header()</code></pre> | |
127 | <p>If this function is declared, and the plugin enabled, it will be called every time Shaarli is rendering the header.</p> | |
128 | <h3 id="plugins-data">Plugin's data</h3> | |
129 | <h4 id="parameters">Parameters</h4> | |
130 | <p>Every hook function has a <code>$data</code> parameter. Its content differs for each hooks.</p> | |
131 | <p><strong>This parameter needs to be returned every time</strong>, otherwise data is lost.</p> | |
132 | <pre><code>return $data;</code></pre> | |
133 | <h4 id="filling-templates-placeholder">Filling templates placeholder</h4> | |
134 | <p>Template placeholders are displayed in template in specific places.</p> | |
135 | <p>RainTPL displays every element contained in the placeholder's array. These element can be added by plugins.</p> | |
136 | <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> | |
137 | <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> | |
138 | <span class="co"># OR</span> | |
139 | <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> | |
140 | ||
141 | <span class="kw">return</span> <span class="kw">$data</span><span class="ot">;</span></code></pre> | |
142 | <h4 id="data-manipulation">Data manipulation</h4> | |
143 | <p>When a page is displayed, every variable send to the template engine is passed to plugins before that in <code>$data</code>.</p> | |
144 | <p>The data contained by this array can be altered before template rendering.</p> | |
145 | <p>For exemple, in linklist, it is possible to alter every title:</p> | |
146 | <pre class="sourceCode php"><code class="sourceCode php"><span class="co">// mind the reference if you want $data to be altered</span> | |
147 | <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> | |
148 | <span class="co">// String reverse every title.</span> | |
149 | <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> | |
150 | } | |
151 | ||
152 | <span class="kw">return</span> <span class="kw">$data</span><span class="ot">;</span></code></pre> | |
153 | <h3 id="its-not-working">It's not working!</h3> | |
154 | <p>Use <code>demo_plugin</code> as a functional example. It covers most of the plugin system features.</p> | |
155 | <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> | |
156 | <h3 id="hooks">Hooks</h3> | |
157 | <table> | |
158 | <thead> | |
159 | <tr class="header"> | |
160 | <th style="text-align: left;">Hooks</th> | |
161 | <th style="text-align: center;">Description</th> | |
162 | </tr> | |
163 | </thead> | |
164 | <tbody> | |
165 | <tr class="odd"> | |
166 | <td style="text-align: left;"><a href="#render_header">render_header</a></td> | |
167 | <td style="text-align: center;">Allow plugin to add content in page headers.</td> | |
168 | </tr> | |
169 | <tr class="even"> | |
170 | <td style="text-align: left;"><a href="#render_includes">render_includes</a></td> | |
171 | <td style="text-align: center;">Allow plugin to include their own CSS files.</td> | |
172 | </tr> | |
173 | <tr class="odd"> | |
174 | <td style="text-align: left;"><a href="#render_footer">render_footer</a></td> | |
175 | <td style="text-align: center;">Allow plugin to add content in page footer and include their own JS files.</td> | |
176 | </tr> | |
177 | <tr class="even"> | |
178 | <td style="text-align: left;"><a href="#render_linklist">render_linklist</a></td> | |
179 | <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> | |
180 | </tr> | |
181 | <tr class="odd"> | |
182 | <td style="text-align: left;"><a href="#render_editlink">render_editlink</a></td> | |
183 | <td style="text-align: center;">Allow to add fields in the form, or display elements.</td> | |
184 | </tr> | |
185 | <tr class="even"> | |
186 | <td style="text-align: left;"><a href="#render_tools">render_tools</a></td> | |
187 | <td style="text-align: center;">Allow to add content at the end of the page.</td> | |
188 | </tr> | |
189 | <tr class="odd"> | |
190 | <td style="text-align: left;"><a href="#render_picwall">render_picwall</a></td> | |
191 | <td style="text-align: center;">Allow to add content at the top and bottom of the page.</td> | |
192 | </tr> | |
193 | <tr class="even"> | |
194 | <td style="text-align: left;"><a href="#render_tagcloud">render_tagcloud</a></td> | |
195 | <td style="text-align: center;">Allow to add content at the top and bottom of the page.</td> | |
196 | </tr> | |
197 | <tr class="odd"> | |
198 | <td style="text-align: left;"><a href="#render_daily">render_daily</a></td> | |
199 | <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> | |
200 | </tr> | |
201 | <tr class="even"> | |
202 | <td style="text-align: left;"><a href="#savelink">savelink</a></td> | |
203 | <td style="text-align: center;">Allow to alter the link being saved in the datastore.</td> | |
204 | </tr> | |
205 | </tbody> | |
206 | </table> | |
207 | <h4 id="render_header">render_header</h4> | |
208 | <p>Triggered on every page.</p> | |
209 | <p>Allow plugin to add content in page headers.</p> | |
210 | <h5 id="data">Data</h5> | |
211 | <p><code>$data</code> is an array containing:</p> | |
212 | <ul> | |
213 | <li><code>_PAGE_</code>: current target page (eg: <code>linklist</code>, <code>picwall</code>, etc.).</li> | |
214 | <li><code>_LOGGEDIN_</code>: true if user is logged in, false otherwise.</li> | |
215 | </ul> | |
216 | <h5 id="template-placeholders">Template placeholders</h5> | |
217 | <p>Items can be displayed in templates by adding an entry in <code>$data['<placeholder>']</code> array.<a href=".html"></a></p> | |
218 | <p>List of placeholders:</p> | |
219 | <ul> | |
220 | <li><code>buttons_toolbar</code>: after the list of buttons in the header.</li> | |
221 | </ul> | |
222 | <p><img src="http://i.imgur.com/ssJUOrt.png" alt="buttons_toolbar_example" /><a href=".html"></a></p> | |
223 | <ul> | |
224 | <li><code>fields_toolbar</code>: after search fields in the header.</li> | |
225 | </ul> | |
226 | <blockquote> | |
227 | <p>Note: This will only be called in linklist.</p> | |
228 | </blockquote> | |
229 | <p><img src="http://i.imgur.com/3GMifI2.png" alt="fields_toolbar_example" /><a href=".html"></a></p> | |
230 | <h4 id="render_includes">render_includes</h4> | |
231 | <p>Triggered on every page.</p> | |
232 | <p>Allow plugin to include their own CSS files.</p> | |
233 | <h5 id="data-1">Data</h5> | |
234 | <p><code>$data</code> is an array containing:</p> | |
235 | <ul> | |
236 | <li><code>_PAGE_</code>: current target page (eg: <code>linklist</code>, <code>picwall</code>, etc.).</li> | |
237 | <li><code>_LOGGEDIN_</code>: true if user is logged in, false otherwise.</li> | |
238 | </ul> | |
239 | <h5 id="template-placeholders-1">Template placeholders</h5> | |
240 | <p>Items can be displayed in templates by adding an entry in <code>$data['<placeholder>']</code> array.<a href=".html"></a></p> | |
241 | <p>List of placeholders:</p> | |
242 | <ul> | |
243 | <li><code>css_files</code>: called after loading default CSS.</li> | |
244 | </ul> | |
245 | <blockquote> | |
246 | <p>Note: only add the path of the CSS file. E.g: <code>plugins/demo_plugin/custom_demo.css</code>.</p> | |
247 | </blockquote> | |
248 | <h4 id="render_footer">render_footer</h4> | |
249 | <p>Triggered on every page.</p> | |
250 | <p>Allow plugin to add content in page footer and include their own JS files.</p> | |
251 | <h5 id="data-2">Data</h5> | |
252 | <p><code>$data</code> is an array containing:</p> | |
253 | <ul> | |
254 | <li><code>_PAGE_</code>: current target page (eg: <code>linklist</code>, <code>picwall</code>, etc.).</li> | |
255 | <li><code>_LOGGEDIN_</code>: true if user is logged in, false otherwise.</li> | |
256 | </ul> | |
257 | <h5 id="template-placeholders-2">Template placeholders</h5> | |
258 | <p>Items can be displayed in templates by adding an entry in <code>$data['<placeholder>']</code> array.<a href=".html"></a></p> | |
259 | <p>List of placeholders:</p> | |
260 | <ul> | |
261 | <li><code>text</code>: called after the end of the footer text.</li> | |
262 | </ul> | |
263 | <p><img src="http://i.imgur.com/L5S2YEH.png" alt="text_example" /><a href=".html"></a></p> | |
264 | <ul> | |
265 | <li><code>js_files</code>: called at the end of the page, to include custom JS scripts.</li> | |
266 | </ul> | |
267 | <blockquote> | |
268 | <p>Note: only add the path of the JS file. E.g: <code>plugins/demo_plugin/custom_demo.js</code>.</p> | |
269 | </blockquote> | |
270 | <h4 id="render_linklist">render_linklist</h4> | |
271 | <p>Triggered when <code>linklist</code> is displayed (list of links, permalink, search, tag filtered, etc.).</p> | |
272 | <p>It allows to add content at the begining and end of the page, after every link displayed and to alter link data.</p> | |
273 | <h5 id="data-3">Data</h5> | |
274 | <p><code>$data</code> is an array containing:</p> | |
275 | <ul> | |
276 | <li><code>_LOGGEDIN_</code>: true if user is logged in, false otherwise.</li> | |
277 | <li>All templates data, including links.</li> | |
278 | </ul> | |
279 | <h5 id="template-placeholders-3">Template placeholders</h5> | |
280 | <p>Items can be displayed in templates by adding an entry in <code>$data['<placeholder>']</code> array.<a href=".html"></a></p> | |
281 | <p>List of placeholders:</p> | |
282 | <ul> | |
283 | <li><code>action_plugin</code>: next to the button "private only" at the top and bottom of the page.</li> | |
284 | </ul> | |
285 | <p><img src="http://i.imgur.com/Q12PWg0.png" alt="action_plugin_example" /><a href=".html"></a></p> | |
286 | <ul> | |
287 | <li><code>link_plugin</code>: for every link, between permalink and link URL.</li> | |
288 | </ul> | |
289 | <p><img src="http://i.imgur.com/3oDPhWx.png" alt="link_plugin_example" /><a href=".html"></a></p> | |
290 | <ul> | |
291 | <li><code>plugin_start_zone</code>: before displaying the template content.</li> | |
292 | </ul> | |
293 | <p><img src="http://i.imgur.com/OVBkGy3.png" alt="plugin_start_zone_example" /><a href=".html"></a></p> | |
294 | <ul> | |
295 | <li><code>plugin_end_zone</code>: after displaying the template content.</li> | |
296 | </ul> | |
297 | <p><img src="http://i.imgur.com/6IoRuop.png" alt="plugin_end_zone_example" /><a href=".html"></a></p> | |
298 | <h4 id="render_editlink">render_editlink</h4> | |
299 | <p>Triggered when the link edition form is displayed.</p> | |
300 | <p>Allow to add fields in the form, or display elements.</p> | |
301 | <h5 id="data-4">Data</h5> | |
302 | <p><code>$data</code> is an array containing:</p> | |
303 | <ul> | |
304 | <li>All templates data.</li> | |
305 | </ul> | |
306 | <h5 id="template-placeholders-4">Template placeholders</h5> | |
307 | <p>Items can be displayed in templates by adding an entry in <code>$data['<placeholder>']</code> array.<a href=".html"></a></p> | |
308 | <p>List of placeholders:</p> | |
309 | <ul> | |
310 | <li><code>edit_link_plugin</code>: after tags field.</li> | |
311 | </ul> | |
312 | <p><img src="http://i.imgur.com/5u17Ens.png" alt="edit_link_plugin_example" /><a href=".html"></a></p> | |
313 | <h4 id="render_tools">render_tools</h4> | |
314 | <p>Triggered when the "tools" page is displayed.</p> | |
315 | <p>Allow to add content at the end of the page.</p> | |
316 | <h5 id="data-5">Data</h5> | |
317 | <p><code>$data</code> is an array containing:</p> | |
318 | <ul> | |
319 | <li>All templates data.</li> | |
320 | </ul> | |
321 | <h5 id="template-placeholders-5">Template placeholders</h5> | |
322 | <p>Items can be displayed in templates by adding an entry in <code>$data['<placeholder>']</code> array.<a href=".html"></a></p> | |
323 | <p>List of placeholders:</p> | |
324 | <ul> | |
325 | <li><code>tools_plugin</code>: at the end of the page.</li> | |
326 | </ul> | |
327 | <p><img src="http://i.imgur.com/Bqhu9oQ.png" alt="tools_plugin_example" /><a href=".html"></a></p> | |
328 | <h4 id="render_picwall">render_picwall</h4> | |
329 | <p>Triggered when picwall is displayed.</p> | |
330 | <p>Allow to add content at the top and bottom of the page.</p> | |
331 | <h5 id="data-6">Data</h5> | |
332 | <p><code>$data</code> is an array containing:</p> | |
333 | <ul> | |
334 | <li><code>_LOGGEDIN_</code>: true if user is logged in, false otherwise.</li> | |
335 | <li>All templates data.</li> | |
336 | </ul> | |
337 | <h5 id="template-placeholders-6">Template placeholders</h5> | |
338 | <p>Items can be displayed in templates by adding an entry in <code>$data['<placeholder>']</code> array.<a href=".html"></a></p> | |
339 | <p>List of placeholders:</p> | |
340 | <ul> | |
341 | <li><p><code>plugin_start_zone</code>: before displaying the template content.</p></li> | |
342 | <li><p><code>plugin_end_zone</code>: after displaying the template content.</p></li> | |
343 | </ul> | |
344 | <p><img src="http://i.imgur.com/tVTQFER.png" alt="plugin_start_end_zone_example" /><a href=".html"></a></p> | |
345 | <h4 id="render_tagcloud">render_tagcloud</h4> | |
346 | <p>Triggered when tagcloud is displayed.</p> | |
347 | <p>Allow to add content at the top and bottom of the page.</p> | |
348 | <h5 id="data-7">Data</h5> | |
349 | <p><code>$data</code> is an array containing:</p> | |
350 | <ul> | |
351 | <li><code>_LOGGEDIN_</code>: true if user is logged in, false otherwise.</li> | |
352 | <li>All templates data.</li> | |
353 | </ul> | |
354 | <h5 id="template-placeholders-7">Template placeholders</h5> | |
355 | <p>Items can be displayed in templates by adding an entry in <code>$data['<placeholder>']</code> array.<a href=".html"></a></p> | |
356 | <p>List of placeholders:</p> | |
357 | <ul> | |
358 | <li><p><code>plugin_start_zone</code>: before displaying the template content.</p></li> | |
359 | <li><p><code>plugin_end_zone</code>: after displaying the template content.</p></li> | |
360 | </ul> | |
361 | <p><img src="http://i.imgur.com/vHmyT3a.png" alt="plugin_start_end_zone_example" /><a href=".html"></a></p> | |
362 | <h4 id="render_daily">render_daily</h4> | |
363 | <p>Triggered when tagcloud is displayed.</p> | |
364 | <p>Allow to add content at the top and bottom of the page, the bottom of each link and to alter data.</p> | |
365 | <h5 id="data-8">Data</h5> | |
366 | <p><code>$data</code> is an array containing:</p> | |
367 | <ul> | |
368 | <li><code>_LOGGEDIN_</code>: true if user is logged in, false otherwise.</li> | |
369 | <li>All templates data, including links.</li> | |
370 | </ul> | |
371 | <h5 id="template-placeholders-8">Template placeholders</h5> | |
372 | <p>Items can be displayed in templates by adding an entry in <code>$data['<placeholder>']</code> array.<a href=".html"></a></p> | |
373 | <p>List of placeholders:</p> | |
374 | <ul> | |
375 | <li><code>link_plugin</code>: used at bottom of each link.</li> | |
376 | </ul> | |
377 | <p><img src="http://i.imgur.com/hzhMfSZ.png" alt="link_plugin_example" /><a href=".html"></a></p> | |
378 | <ul> | |
379 | <li><p><code>plugin_start_zone</code>: before displaying the template content.</p></li> | |
380 | <li><p><code>plugin_end_zone</code>: after displaying the template content.</p></li> | |
381 | </ul> | |
382 | <h4 id="savelink">savelink</h4> | |
383 | <p>Triggered when a link is save (new link or edit).</p> | |
384 | <p>Allow to alter the link being saved in the datastore.</p> | |
385 | <h5 id="data-9">Data</h5> | |
386 | <p><code>$data</code> is an array containing the link being saved:</p> | |
387 | <ul> | |
388 | <li>title</li> | |
389 | <li>url</li> | |
390 | <li>description</li> | |
391 | <li>linkdate</li> | |
392 | <li>private</li> | |
393 | <li>tags</li> | |
394 | </ul> | |
395 | <h2 id="guide-for-template-designer">Guide for template designer</h2> | |
396 | <h3 id="placeholder-system">Placeholder system</h3> | |
397 | <p>In order to make plugins work with every custom themes, you need to add variable placeholder in your templates.</p> | |
398 | <p>It's a RainTPL loop like this:</p> | |
399 | <pre><code>{loop="$plugin_variable"} | |
400 | {$value} | |
401 | {/loop}</code></pre> | |
402 | <p>You should enable <code>demo_plugin</code> for testing purpose, since it uses every placeholder available.</p> | |
403 | <h3 id="list-of-placeholders">List of placeholders</h3> | |
404 | <p><strong>page.header.html</strong></p> | |
405 | <p>At the end of the menu:</p> | |
406 | <pre><code>{loop="$plugins_header.buttons_toolbar"} | |
407 | {$value} | |
408 | {/loop}</code></pre> | |
409 | <p><strong>includes.html</strong></p> | |
410 | <p>At the end of the file:</p> | |
411 | <pre class="sourceCode html"><code class="sourceCode html">{loop="$plugins_includes.css_files"} | |
412 | <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> | |
413 | {/loop}</code></pre> | |
414 | <p><strong>page.footer.html</strong></p> | |
415 | <p>At the end of your footer notes:</p> | |
416 | <pre class="sourceCode html"><code class="sourceCode html">{loop="$plugins_footer.text"} | |
417 | {$value} | |
418 | {/loop}</code></pre> | |
419 | <p>At the end of file:</p> | |
420 | <pre class="sourceCode html"><code class="sourceCode html">{loop="$plugins_footer.js_files"} | |
421 | <span class="kw"><script</span><span class="ot"> src=</span><span class="st">"{$value}#"</span><span class="kw">></script></span> | |
422 | {/loop}</code></pre> | |
423 | <p><strong>linklist.html</strong></p> | |
424 | <p>After search fields:</p> | |
425 | <pre class="sourceCode html"><code class="sourceCode html">{loop="$plugins_header.fields_toolbar"} | |
426 | {$value} | |
427 | {/loop}</code></pre> | |
428 | <p>Before displaying the link list (after paging):</p> | |
429 | <pre class="sourceCode html"><code class="sourceCode html">{loop="$plugin_start_zone"} | |
430 | {$value} | |
431 | {/loop}</code></pre> | |
432 | <p>For every links (icons):</p> | |
433 | <pre class="sourceCode html"><code class="sourceCode html">{loop="$value.link_plugin"} | |
434 | <span class="kw"><span></span>{$value}<span class="kw"></span></span> | |
435 | {/loop}</code></pre> | |
436 | <p>Before end paging:</p> | |
437 | <pre class="sourceCode html"><code class="sourceCode html">{loop="$plugin_end_zone"} | |
438 | {$value} | |
439 | {/loop}</code></pre> | |
440 | <p><strong>linklist.paging.html</strong></p> | |
441 | <p>After the "private only" icon:</p> | |
442 | <pre class="sourceCode html"><code class="sourceCode html">{loop="$action_plugin"} | |
443 | {$value} | |
444 | {/loop}</code></pre> | |
445 | <p><strong>editlink.html</strong></p> | |
446 | <p>After tags field:</p> | |
447 | <pre class="sourceCode html"><code class="sourceCode html">{loop="$edit_link_plugin"} | |
448 | {$value} | |
449 | {/loop}</code></pre> | |
450 | <p><strong>tools.html</strong></p> | |
451 | <p>After the last tool:</p> | |
452 | <pre class="sourceCode html"><code class="sourceCode html">{loop="$tools_plugin"} | |
453 | {$value} | |
454 | {/loop}</code></pre> | |
455 | <p><strong>picwall.html</strong></p> | |
456 | <p>Top:</p> | |
457 | <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> | |
458 | {loop="$plugin_start_zone"} | |
459 | {$value} | |
460 | {/loop} | |
461 | <span class="kw"></div></span></code></pre> | |
462 | <p>Bottom:</p> | |
463 | <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> | |
464 | {loop="$plugin_end_zone"} | |
465 | {$value} | |
466 | {/loop} | |
467 | <span class="kw"></div></span></code></pre> | |
468 | <p><strong>tagcloud.html</strong></p> | |
469 | <p>Top:</p> | |
470 | <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> | |
471 | {loop="$plugin_start_zone"} | |
472 | {$value} | |
473 | {/loop} | |
474 | <span class="kw"></div></span></code></pre> | |
475 | <p>Bottom:</p> | |
476 | <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> | |
477 | {loop="$plugin_end_zone"} | |
478 | {$value} | |
479 | {/loop} | |
480 | <span class="kw"></div></span></code></pre> | |
481 | <p><strong>daily.html</strong></p> | |
482 | <p>Top:</p> | |
483 | <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> | |
484 | {loop="$plugin_start_zone"} | |
485 | {$value} | |
486 | {/loop} | |
487 | <span class="kw"></div></span></code></pre> | |
488 | <p>After every link:</p> | |
489 | <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> | |
490 | {loop="$link.link_plugin"} | |
491 | {$value} | |
492 | {/loop} | |
493 | <span class="kw"></div></span></code></pre> | |
494 | <p>Bottom:</p> | |
495 | <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> | |
496 | {loop="$plugin_end_zone"} | |
497 | {$value} | |
498 | {/loop} | |
499 | <span class="kw"></div></span></code></pre> | |
500 | </body> | |
501 | </html> |