Plugin-System.html 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541
  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-&amp;-Related-software.html">Community &amp; 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_&lt;plugin_name&gt;_&lt;hook_name&gt;</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">&#39;top_placeholder&#39;</span><span class="ot">[]</span> = <span class="st">&#39;My content&#39;</span><span class="ot">;](]</span>-=-<span class="st">&#39;My-content&#39;</span><span class="ot">;</span>.html<span class="ot">)</span>
  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">&#39;top_placeholder&#39;</span><span class="ot">],</span> <span class="st">&#39;My&#39;</span><span class="ot">,</span> <span class="st">&#39;content&#39;</span><span class="ot">);[](</span>.html<span class="ot">)</span>
  143. <span class="kw">return</span> <span class="kw">$data</span><span class="ot">;</span></code></pre></div>
  144. <h4 id="data-manipulation">Data manipulation</h4>
  145. <p>When a page is displayed, every variable send to the template engine is passed to plugins before that in <code>$data</code>.</p>
  146. <p>The data contained by this array can be altered before template rendering.</p>
  147. <p>For exemple, in linklist, it is possible to alter every title:</p>
  148. <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>
  149. <span class="kw">foreach</span> <span class="ot">(</span><span class="kw">$data</span><span class="ot">[</span><span class="st">&#39;links&#39;</span><span class="ot">]</span> <span class="kw">as</span> &amp;<span class="kw">$value</span><span class="ot">)</span> {<span class="ot">[](</span>.html<span class="ot">)</span>
  150. <span class="co">// String reverse every title.</span>
  151. <span class="kw">$value</span><span class="ot">[</span><span class="st">&#39;title&#39;</span><span class="ot">]</span> = <span class="fu">strrev</span><span class="ot">(</span><span class="kw">$value</span><span class="ot">[</span><span class="st">&#39;title&#39;</span><span class="ot">]);[](</span>.html<span class="ot">)</span>
  152. }
  153. <span class="kw">return</span> <span class="kw">$data</span><span class="ot">;</span></code></pre></div>
  154. <h3 id="metadata">Metadata</h3>
  155. <p>Every plugin needs a <code>&lt;plugin_name&gt;.meta</code> file, which is in fact an <code>.ini</code> file (<code>KEY=&quot;VALUE&quot;</code>), to be listed in plugin administration.</p>
  156. <p>Each file contain two keys:</p>
  157. <ul>
  158. <li><code>description</code>: plugin description</li>
  159. <li><code>parameters</code>: user parameter names, separated by a <code>;</code>.</li>
  160. </ul>
  161. <blockquote>
  162. <p>Note: In PHP, <code>parse_ini_file()</code> seems to want strings to be between by quotes <code>&quot;</code> in the ini file.</p>
  163. </blockquote>
  164. <h3 id="its-not-working">It's not working!</h3>
  165. <p>Use <code>demo_plugin</code> as a functional example. It covers most of the plugin system features.</p>
  166. <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>
  167. <h3 id="hooks">Hooks</h3>
  168. <table style="width:42%;">
  169. <colgroup>
  170. <col style="width: 19%" />
  171. <col style="width: 22%" />
  172. </colgroup>
  173. <thead>
  174. <tr class="header">
  175. <th>Hooks</th>
  176. <th style="text-align: center;">Description</th>
  177. </tr>
  178. </thead>
  179. <tbody>
  180. <tr class="odd">
  181. <td><a href="#render_header">render_header</a></td>
  182. <td style="text-align: center;">Allow plugin to add content in page headers.</td>
  183. </tr>
  184. <tr class="even">
  185. <td><a href="#render_includes">render_includes</a></td>
  186. <td style="text-align: center;">Allow plugin to include their own CSS files.</td>
  187. </tr>
  188. <tr class="odd">
  189. <td><a href="#render_footer">render_footer</a></td>
  190. <td style="text-align: center;">Allow plugin to add content in page footer and include their own JS files.</td>
  191. </tr>
  192. <tr class="even">
  193. <td><a href="#render_linklist">render_linklist</a></td>
  194. <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>
  195. </tr>
  196. <tr class="odd">
  197. <td><a href="#render_editlink">render_editlink</a></td>
  198. <td style="text-align: center;">Allow to add fields in the form, or display elements.</td>
  199. </tr>
  200. <tr class="even">
  201. <td><a href="#render_tools">render_tools</a></td>
  202. <td style="text-align: center;">Allow to add content at the end of the page.</td>
  203. </tr>
  204. <tr class="odd">
  205. <td><a href="#render_picwall">render_picwall</a></td>
  206. <td style="text-align: center;">Allow to add content at the top and bottom of the page.</td>
  207. </tr>
  208. <tr class="even">
  209. <td><a href="#render_tagcloud">render_tagcloud</a></td>
  210. <td style="text-align: center;">Allow to add content at the top and bottom of the page.</td>
  211. </tr>
  212. <tr class="odd">
  213. <td><a href="#render_daily">render_daily</a></td>
  214. <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>
  215. </tr>
  216. <tr class="even">
  217. <td><a href="#savelink">savelink</a></td>
  218. <td style="text-align: center;">Allow to alter the link being saved in the datastore.</td>
  219. </tr>
  220. </tbody>
  221. </table>
  222. <h4 id="render_header">render_header</h4>
  223. <p>Triggered on every page.</p>
  224. <p>Allow plugin to add content in page headers.</p>
  225. <h5 id="data">Data</h5>
  226. <p><code>$data</code> is an array containing:</p>
  227. <ul>
  228. <li><code>_PAGE_</code>: current target page (eg: <code>linklist</code>, <code>picwall</code>, etc.).</li>
  229. <li><code>_LOGGEDIN_</code>: true if user is logged in, false otherwise.</li>
  230. </ul>
  231. <h5 id="template-placeholders">Template placeholders</h5>
  232. <p>Items can be displayed in templates by adding an entry in <code>$data['&lt;placeholder&gt;']</code> array.<a href=".html"></a></p>
  233. <p>List of placeholders:</p>
  234. <ul>
  235. <li><code>buttons_toolbar</code>: after the list of buttons in the header.</li>
  236. </ul>
  237. <p><img src="http://i.imgur.com/ssJUOrt.png" alt="buttons_toolbar_example" /><a href=".html"></a></p>
  238. <ul>
  239. <li><code>fields_toolbar</code>: after search fields in the header.</li>
  240. </ul>
  241. <blockquote>
  242. <p>Note: This will only be called in linklist.</p>
  243. </blockquote>
  244. <p><img src="http://i.imgur.com/3GMifI2.png" alt="fields_toolbar_example" /><a href=".html"></a></p>
  245. <h4 id="render_includes">render_includes</h4>
  246. <p>Triggered on every page.</p>
  247. <p>Allow plugin to include their own CSS files.</p>
  248. <h5 id="data-1">Data</h5>
  249. <p><code>$data</code> is an array containing:</p>
  250. <ul>
  251. <li><code>_PAGE_</code>: current target page (eg: <code>linklist</code>, <code>picwall</code>, etc.).</li>
  252. <li><code>_LOGGEDIN_</code>: true if user is logged in, false otherwise.</li>
  253. </ul>
  254. <h5 id="template-placeholders-1">Template placeholders</h5>
  255. <p>Items can be displayed in templates by adding an entry in <code>$data['&lt;placeholder&gt;']</code> array.<a href=".html"></a></p>
  256. <p>List of placeholders:</p>
  257. <ul>
  258. <li><code>css_files</code>: called after loading default CSS.</li>
  259. </ul>
  260. <blockquote>
  261. <p>Note: only add the path of the CSS file. E.g: <code>plugins/demo_plugin/custom_demo.css</code>.</p>
  262. </blockquote>
  263. <h4 id="render_footer">render_footer</h4>
  264. <p>Triggered on every page.</p>
  265. <p>Allow plugin to add content in page footer and include their own JS files.</p>
  266. <h5 id="data-2">Data</h5>
  267. <p><code>$data</code> is an array containing:</p>
  268. <ul>
  269. <li><code>_PAGE_</code>: current target page (eg: <code>linklist</code>, <code>picwall</code>, etc.).</li>
  270. <li><code>_LOGGEDIN_</code>: true if user is logged in, false otherwise.</li>
  271. </ul>
  272. <h5 id="template-placeholders-2">Template placeholders</h5>
  273. <p>Items can be displayed in templates by adding an entry in <code>$data['&lt;placeholder&gt;']</code> array.<a href=".html"></a></p>
  274. <p>List of placeholders:</p>
  275. <ul>
  276. <li><code>text</code>: called after the end of the footer text.</li>
  277. <li><code>endofpage</code>: called at the end of the page.</li>
  278. </ul>
  279. <p><img src="http://i.imgur.com/L5S2YEH.png" alt="text_example" /><a href=".html"></a></p>
  280. <ul>
  281. <li><code>js_files</code>: called at the end of the page, to include custom JS scripts.</li>
  282. </ul>
  283. <blockquote>
  284. <p>Note: only add the path of the JS file. E.g: <code>plugins/demo_plugin/custom_demo.js</code>.</p>
  285. </blockquote>
  286. <h4 id="render_linklist">render_linklist</h4>
  287. <p>Triggered when <code>linklist</code> is displayed (list of links, permalink, search, tag filtered, etc.).</p>
  288. <p>It allows to add content at the begining and end of the page, after every link displayed and to alter link data.</p>
  289. <h5 id="data-3">Data</h5>
  290. <p><code>$data</code> is an array containing:</p>
  291. <ul>
  292. <li><code>_LOGGEDIN_</code>: true if user is logged in, false otherwise.</li>
  293. <li>All templates data, including links.</li>
  294. </ul>
  295. <h5 id="template-placeholders-3">Template placeholders</h5>
  296. <p>Items can be displayed in templates by adding an entry in <code>$data['&lt;placeholder&gt;']</code> array.<a href=".html"></a></p>
  297. <p>List of placeholders:</p>
  298. <ul>
  299. <li><code>action_plugin</code>: next to the button &quot;private only&quot; at the top and bottom of the page.</li>
  300. </ul>
  301. <p><img src="http://i.imgur.com/Q12PWg0.png" alt="action_plugin_example" /><a href=".html"></a></p>
  302. <ul>
  303. <li><code>link_plugin</code>: for every link, between permalink and link URL.</li>
  304. </ul>
  305. <p><img src="http://i.imgur.com/3oDPhWx.png" alt="link_plugin_example" /><a href=".html"></a></p>
  306. <ul>
  307. <li><code>plugin_start_zone</code>: before displaying the template content.</li>
  308. </ul>
  309. <p><img src="http://i.imgur.com/OVBkGy3.png" alt="plugin_start_zone_example" /><a href=".html"></a></p>
  310. <ul>
  311. <li><code>plugin_end_zone</code>: after displaying the template content.</li>
  312. </ul>
  313. <p><img src="http://i.imgur.com/6IoRuop.png" alt="plugin_end_zone_example" /><a href=".html"></a></p>
  314. <h4 id="render_editlink">render_editlink</h4>
  315. <p>Triggered when the link edition form is displayed.</p>
  316. <p>Allow to add fields in the form, or display elements.</p>
  317. <h5 id="data-4">Data</h5>
  318. <p><code>$data</code> is an array containing:</p>
  319. <ul>
  320. <li>All templates data.</li>
  321. </ul>
  322. <h5 id="template-placeholders-4">Template placeholders</h5>
  323. <p>Items can be displayed in templates by adding an entry in <code>$data['&lt;placeholder&gt;']</code> array.<a href=".html"></a></p>
  324. <p>List of placeholders:</p>
  325. <ul>
  326. <li><code>edit_link_plugin</code>: after tags field.</li>
  327. </ul>
  328. <p><img src="http://i.imgur.com/5u17Ens.png" alt="edit_link_plugin_example" /><a href=".html"></a></p>
  329. <h4 id="render_tools">render_tools</h4>
  330. <p>Triggered when the &quot;tools&quot; page is displayed.</p>
  331. <p>Allow to add content at the end of the page.</p>
  332. <h5 id="data-5">Data</h5>
  333. <p><code>$data</code> is an array containing:</p>
  334. <ul>
  335. <li>All templates data.</li>
  336. </ul>
  337. <h5 id="template-placeholders-5">Template placeholders</h5>
  338. <p>Items can be displayed in templates by adding an entry in <code>$data['&lt;placeholder&gt;']</code> array.<a href=".html"></a></p>
  339. <p>List of placeholders:</p>
  340. <ul>
  341. <li><code>tools_plugin</code>: at the end of the page.</li>
  342. </ul>
  343. <p><img src="http://i.imgur.com/Bqhu9oQ.png" alt="tools_plugin_example" /><a href=".html"></a></p>
  344. <h4 id="render_picwall">render_picwall</h4>
  345. <p>Triggered when picwall is displayed.</p>
  346. <p>Allow to add content at the top and bottom of the page.</p>
  347. <h5 id="data-6">Data</h5>
  348. <p><code>$data</code> is an array containing:</p>
  349. <ul>
  350. <li><code>_LOGGEDIN_</code>: true if user is logged in, false otherwise.</li>
  351. <li>All templates data.</li>
  352. </ul>
  353. <h5 id="template-placeholders-6">Template placeholders</h5>
  354. <p>Items can be displayed in templates by adding an entry in <code>$data['&lt;placeholder&gt;']</code> array.<a href=".html"></a></p>
  355. <p>List of placeholders:</p>
  356. <ul>
  357. <li><p><code>plugin_start_zone</code>: before displaying the template content.</p></li>
  358. <li><p><code>plugin_end_zone</code>: after displaying the template content.</p></li>
  359. </ul>
  360. <p><img src="http://i.imgur.com/tVTQFER.png" alt="plugin_start_end_zone_example" /><a href=".html"></a></p>
  361. <h4 id="render_tagcloud">render_tagcloud</h4>
  362. <p>Triggered when tagcloud is displayed.</p>
  363. <p>Allow to add content at the top and bottom of the page.</p>
  364. <h5 id="data-7">Data</h5>
  365. <p><code>$data</code> is an array containing:</p>
  366. <ul>
  367. <li><code>_LOGGEDIN_</code>: true if user is logged in, false otherwise.</li>
  368. <li>All templates data.</li>
  369. </ul>
  370. <h5 id="template-placeholders-7">Template placeholders</h5>
  371. <p>Items can be displayed in templates by adding an entry in <code>$data['&lt;placeholder&gt;']</code> array.<a href=".html"></a></p>
  372. <p>List of placeholders:</p>
  373. <ul>
  374. <li><p><code>plugin_start_zone</code>: before displaying the template content.</p></li>
  375. <li><p><code>plugin_end_zone</code>: after displaying the template content.</p></li>
  376. </ul>
  377. <p><img src="http://i.imgur.com/vHmyT3a.png" alt="plugin_start_end_zone_example" /><a href=".html"></a></p>
  378. <h4 id="render_daily">render_daily</h4>
  379. <p>Triggered when tagcloud is displayed.</p>
  380. <p>Allow to add content at the top and bottom of the page, the bottom of each link and to alter data.</p>
  381. <h5 id="data-8">Data</h5>
  382. <p><code>$data</code> is an array containing:</p>
  383. <ul>
  384. <li><code>_LOGGEDIN_</code>: true if user is logged in, false otherwise.</li>
  385. <li>All templates data, including links.</li>
  386. </ul>
  387. <h5 id="template-placeholders-8">Template placeholders</h5>
  388. <p>Items can be displayed in templates by adding an entry in <code>$data['&lt;placeholder&gt;']</code> array.<a href=".html"></a></p>
  389. <p>List of placeholders:</p>
  390. <ul>
  391. <li><code>link_plugin</code>: used at bottom of each link.</li>
  392. </ul>
  393. <p><img src="http://i.imgur.com/hzhMfSZ.png" alt="link_plugin_example" /><a href=".html"></a></p>
  394. <ul>
  395. <li><p><code>plugin_start_zone</code>: before displaying the template content.</p></li>
  396. <li><p><code>plugin_end_zone</code>: after displaying the template content.</p></li>
  397. </ul>
  398. <h4 id="savelink">savelink</h4>
  399. <p>Triggered when a link is save (new link or edit).</p>
  400. <p>Allow to alter the link being saved in the datastore.</p>
  401. <h5 id="data-9">Data</h5>
  402. <p><code>$data</code> is an array containing the link being saved:</p>
  403. <ul>
  404. <li>title</li>
  405. <li>url</li>
  406. <li>description</li>
  407. <li>linkdate</li>
  408. <li>private</li>
  409. <li>tags</li>
  410. </ul>
  411. <h2 id="guide-for-template-designer">Guide for template designer</h2>
  412. <h3 id="plugin-administration">Plugin administration</h3>
  413. <p>Your theme must include a plugin administration page: <code>pluginsadmin.html</code>.</p>
  414. <blockquote>
  415. <p>Note: repo's template link needs to be added when the PR is merged.</p>
  416. </blockquote>
  417. <p>Use the default one as an example.</p>
  418. <p>Aside from classic RainTPL loops, plugins order is handle by JavaScript. You can just include <code>plugin_admin.js</code>, only if:</p>
  419. <ul>
  420. <li>you're using a table.</li>
  421. <li>you call orderUp() and orderUp() onclick on arrows.</li>
  422. <li>you add data-line and data-order to your rows.</li>
  423. </ul>
  424. <p>Otherwise, you can use your own JS as long as this field is send by the form:</p>
  425. <p><input type="hidden" name="order_{$key}" value="{$counter}"></p>
  426. <h3 id="placeholder-system">Placeholder system</h3>
  427. <p>In order to make plugins work with every custom themes, you need to add variable placeholder in your templates.</p>
  428. <p>It's a RainTPL loop like this:</p>
  429. <pre><code>{loop=&quot;$plugin_variable&quot;}
  430. {$value}
  431. {/loop}</code></pre>
  432. <p>You should enable <code>demo_plugin</code> for testing purpose, since it uses every placeholder available.</p>
  433. <h3 id="list-of-placeholders">List of placeholders</h3>
  434. <p><strong>page.header.html</strong></p>
  435. <p>At the end of the menu:</p>
  436. <pre><code>{loop=&quot;$plugins_header.buttons_toolbar&quot;}
  437. {$value}
  438. {/loop}</code></pre>
  439. <p>At the end of file, before clearing floating blocks:</p>
  440. <pre><code>{if=&quot;!empty($plugin_errors) &amp;&amp; isLoggedIn()&quot;}
  441. &lt;ul class=&quot;errors&quot;&gt;
  442. {loop=&quot;plugin_errors&quot;}
  443. &lt;li&gt;{$value}&lt;/li&gt;
  444. {/loop}
  445. &lt;/ul&gt;
  446. {/if}</code></pre>
  447. <p><strong>includes.html</strong></p>
  448. <p>At the end of the file:</p>
  449. <div class="sourceCode"><pre class="sourceCode html"><code class="sourceCode html">{loop=&quot;$plugins_includes.css_files&quot;}
  450. <span class="kw">&lt;link</span><span class="ot"> type=</span><span class="st">&quot;text/css&quot;</span><span class="ot"> rel=</span><span class="st">&quot;stylesheet&quot;</span><span class="ot"> href=</span><span class="st">&quot;{$value}#&quot;</span><span class="kw">/&gt;</span>
  451. {/loop}</code></pre></div>
  452. <p><strong>page.footer.html</strong></p>
  453. <p>At the end of your footer notes:</p>
  454. <div class="sourceCode"><pre class="sourceCode html"><code class="sourceCode html">{loop=&quot;$plugins_footer.text&quot;}
  455. {$value}
  456. {/loop}</code></pre></div>
  457. <p>At the end of file:</p>
  458. <div class="sourceCode"><pre class="sourceCode html"><code class="sourceCode html">{loop=&quot;$plugins_footer.js_files&quot;}
  459. <span class="kw">&lt;script</span><span class="ot"> src=</span><span class="st">&quot;{$value}#&quot;</span><span class="kw">&gt;&lt;/script&gt;</span>
  460. {/loop}</code></pre></div>
  461. <p><strong>linklist.html</strong></p>
  462. <p>After search fields:</p>
  463. <div class="sourceCode"><pre class="sourceCode html"><code class="sourceCode html">{loop=&quot;$plugins_header.fields_toolbar&quot;}
  464. {$value}
  465. {/loop}</code></pre></div>
  466. <p>Before displaying the link list (after paging):</p>
  467. <div class="sourceCode"><pre class="sourceCode html"><code class="sourceCode html">{loop=&quot;$plugin_start_zone&quot;}
  468. {$value}
  469. {/loop}</code></pre></div>
  470. <p>For every links (icons):</p>
  471. <div class="sourceCode"><pre class="sourceCode html"><code class="sourceCode html">{loop=&quot;$value.link_plugin&quot;}
  472. <span class="kw">&lt;span&gt;</span>{$value}<span class="kw">&lt;/span&gt;</span>
  473. {/loop}</code></pre></div>
  474. <p>Before end paging:</p>
  475. <div class="sourceCode"><pre class="sourceCode html"><code class="sourceCode html">{loop=&quot;$plugin_end_zone&quot;}
  476. {$value}
  477. {/loop}</code></pre></div>
  478. <p><strong>linklist.paging.html</strong></p>
  479. <p>After the &quot;private only&quot; icon:</p>
  480. <div class="sourceCode"><pre class="sourceCode html"><code class="sourceCode html">{loop=&quot;$action_plugin&quot;}
  481. {$value}
  482. {/loop}</code></pre></div>
  483. <p><strong>editlink.html</strong></p>
  484. <p>After tags field:</p>
  485. <div class="sourceCode"><pre class="sourceCode html"><code class="sourceCode html">{loop=&quot;$edit_link_plugin&quot;}
  486. {$value}
  487. {/loop}</code></pre></div>
  488. <p><strong>tools.html</strong></p>
  489. <p>After the last tool:</p>
  490. <div class="sourceCode"><pre class="sourceCode html"><code class="sourceCode html">{loop=&quot;$tools_plugin&quot;}
  491. {$value}
  492. {/loop}</code></pre></div>
  493. <p><strong>picwall.html</strong></p>
  494. <p>Top:</p>
  495. <div class="sourceCode"><pre class="sourceCode html"><code class="sourceCode html"><span class="kw">&lt;div</span><span class="ot"> id=</span><span class="st">&quot;plugin_zone_start_picwall&quot;</span><span class="ot"> class=</span><span class="st">&quot;plugin_zone&quot;</span><span class="kw">&gt;</span>
  496. {loop=&quot;$plugin_start_zone&quot;}
  497. {$value}
  498. {/loop}
  499. <span class="kw">&lt;/div&gt;</span></code></pre></div>
  500. <p>Bottom:</p>
  501. <div class="sourceCode"><pre class="sourceCode html"><code class="sourceCode html"><span class="kw">&lt;div</span><span class="ot"> id=</span><span class="st">&quot;plugin_zone_end_picwall&quot;</span><span class="ot"> class=</span><span class="st">&quot;plugin_zone&quot;</span><span class="kw">&gt;</span>
  502. {loop=&quot;$plugin_end_zone&quot;}
  503. {$value}
  504. {/loop}
  505. <span class="kw">&lt;/div&gt;</span></code></pre></div>
  506. <p><strong>tagcloud.html</strong></p>
  507. <p>Top:</p>
  508. <div class="sourceCode"><pre class="sourceCode html"><code class="sourceCode html"> <span class="kw">&lt;div</span><span class="ot"> id=</span><span class="st">&quot;plugin_zone_start_tagcloud&quot;</span><span class="ot"> class=</span><span class="st">&quot;plugin_zone&quot;</span><span class="kw">&gt;</span>
  509. {loop=&quot;$plugin_start_zone&quot;}
  510. {$value}
  511. {/loop}
  512. <span class="kw">&lt;/div&gt;</span></code></pre></div>
  513. <p>Bottom:</p>
  514. <div class="sourceCode"><pre class="sourceCode html"><code class="sourceCode html"> <span class="kw">&lt;div</span><span class="ot"> id=</span><span class="st">&quot;plugin_zone_end_tagcloud&quot;</span><span class="ot"> class=</span><span class="st">&quot;plugin_zone&quot;</span><span class="kw">&gt;</span>
  515. {loop=&quot;$plugin_end_zone&quot;}
  516. {$value}
  517. {/loop}
  518. <span class="kw">&lt;/div&gt;</span></code></pre></div>
  519. <p><strong>daily.html</strong></p>
  520. <p>Top:</p>
  521. <div class="sourceCode"><pre class="sourceCode html"><code class="sourceCode html"><span class="kw">&lt;div</span><span class="ot"> id=</span><span class="st">&quot;plugin_zone_start_picwall&quot;</span><span class="ot"> class=</span><span class="st">&quot;plugin_zone&quot;</span><span class="kw">&gt;</span>
  522. {loop=&quot;$plugin_start_zone&quot;}
  523. {$value}
  524. {/loop}
  525. <span class="kw">&lt;/div&gt;</span></code></pre></div>
  526. <p>After every link:</p>
  527. <div class="sourceCode"><pre class="sourceCode html"><code class="sourceCode html"><span class="kw">&lt;div</span><span class="ot"> class=</span><span class="st">&quot;dailyEntryFooter&quot;</span><span class="kw">&gt;</span>
  528. {loop=&quot;$link.link_plugin&quot;}
  529. {$value}
  530. {/loop}
  531. <span class="kw">&lt;/div&gt;</span></code></pre></div>
  532. <p>Bottom:</p>
  533. <div class="sourceCode"><pre class="sourceCode html"><code class="sourceCode html"><span class="kw">&lt;div</span><span class="ot"> id=</span><span class="st">&quot;plugin_zone_end_picwall&quot;</span><span class="ot"> class=</span><span class="st">&quot;plugin_zone&quot;</span><span class="kw">&gt;</span>
  534. {loop=&quot;$plugin_end_zone&quot;}
  535. {$value}
  536. {/loop}
  537. <span class="kw">&lt;/div&gt;</span></code></pre></div>
  538. </body>
  539. </html>