aboutsummaryrefslogtreecommitdiffhomepage
path: root/doc/md/Plugin-System.md
diff options
context:
space:
mode:
Diffstat (limited to 'doc/md/Plugin-System.md')
-rw-r--r--doc/md/Plugin-System.md68
1 files changed, 45 insertions, 23 deletions
diff --git a/doc/md/Plugin-System.md b/doc/md/Plugin-System.md
index f264e873..87a2638d 100644
--- a/doc/md/Plugin-System.md
+++ b/doc/md/Plugin-System.md
@@ -73,6 +73,26 @@ Every hook function has a `$data` parameter. Its content differs for each hooks.
73 73
74 return $data; 74 return $data;
75 75
76#### Special data
77
78Special additional data are passed to every hook through the
79`$data` parameter to give you access to additional context, and services.
80
81Complete list:
82
83 * `_PAGE_` (string): if the current hook is used to render a template, its name is passed through this additional parameter.
84 * `_LOGGEDIN_` (bool): whether the user is logged in or not.
85 * `_BASE_PATH_` (string): if Shaarli instance is hosted under a subfolder, contains the subfolder path to `index.php` (e.g. `https://domain.tld/shaarli/` -> `/shaarli/`).
86 * `_BOOKMARK_SERVICE_` (`BookmarkServiceInterface`): bookmark service instance, for advanced usage.
87
88Example:
89
90```php
91if ($data['_PAGE_'] === TemplatePage::LINKLIST && $data['LOGGEDIN'] === true) {
92 // Do something for logged in users when the link list is rendered
93}
94```
95
76#### Filling templates placeholder 96#### Filling templates placeholder
77 97
78Template placeholders are displayed in template in specific places. 98Template placeholders are displayed in template in specific places.
@@ -95,7 +115,7 @@ When a page is displayed, every variable send to the template engine is passed t
95 115
96The data contained by this array can be altered before template rendering. 116The data contained by this array can be altered before template rendering.
97 117
98For exemple, in linklist, it is possible to alter every title: 118For example, in linklist, it is possible to alter every title:
99 119
100```php 120```php
101// mind the reference if you want $data to be altered 121// mind the reference if you want $data to be altered
@@ -156,8 +176,7 @@ Allow plugin to add content in page headers.
156 176
157`$data` is an array containing: 177`$data` is an array containing:
158 178
159- `_PAGE_`: current target page (eg: `linklist`, `picwall`, etc.). 179 - [Special data](#special-data)
160- `_LOGGEDIN_`: true if user is logged in, false otherwise.
161 180
162##### Template placeholders 181##### Template placeholders
163 182
@@ -185,8 +204,7 @@ Allow plugin to include their own CSS files.
185 204
186`$data` is an array containing: 205`$data` is an array containing:
187 206
188- `_PAGE_`: current target page (eg: `linklist`, `picwall`, etc.). 207 - [Special data](#special-data)
189- `_LOGGEDIN_`: true if user is logged in, false otherwise.
190 208
191##### Template placeholders 209##### Template placeholders
192 210
@@ -208,8 +226,7 @@ Allow plugin to add content in page footer and include their own JS files.
208 226
209`$data` is an array containing: 227`$data` is an array containing:
210 228
211- `_PAGE_`: current target page (eg: `linklist`, `picwall`, etc.). 229 - [Special data](#special-data)
212- `_LOGGEDIN_`: true if user is logged in, false otherwise.
213 230
214##### Template placeholders 231##### Template placeholders
215 232
@@ -236,8 +253,8 @@ It allows to add content at the begining and end of the page, after every link d
236 253
237`$data` is an array containing: 254`$data` is an array containing:
238 255
239- `_LOGGEDIN_`: true if user is logged in, false otherwise. 256 - All templates data, including links.
240- All templates data, including links. 257 - [Special data](#special-data)
241 258
242##### Template placeholders 259##### Template placeholders
243 260
@@ -271,7 +288,8 @@ Allow to add fields in the form, or display elements.
271 288
272`$data` is an array containing: 289`$data` is an array containing:
273 290
274- All templates data. 291 - All templates data.
292 - [Special data](#special-data)
275 293
276##### Template placeholders 294##### Template placeholders
277 295
@@ -293,7 +311,8 @@ Allow to add content at the end of the page.
293 311
294`$data` is an array containing: 312`$data` is an array containing:
295 313
296- All templates data. 314 - All templates data.
315 - [Special data](#special-data)
297 316
298##### Template placeholders 317##### Template placeholders
299 318
@@ -315,8 +334,8 @@ Allow to add content at the top and bottom of the page.
315 334
316`$data` is an array containing: 335`$data` is an array containing:
317 336
318- `_LOGGEDIN_`: true if user is logged in, false otherwise. 337 - All templates data.
319- All templates data. 338 - [Special data](#special-data)
320 339
321##### Template placeholders 340##### Template placeholders
322 341
@@ -339,8 +358,8 @@ Allow to add content at the top and bottom of the page.
339 358
340`$data` is an array containing: 359`$data` is an array containing:
341 360
342- `_LOGGEDIN_`: true if user is logged in, false otherwise. 361 - All templates data.
343- All templates data. 362 - [Special data](#special-data)
344 363
345##### Template placeholders 364##### Template placeholders
346 365
@@ -368,8 +387,8 @@ Allow to add content at the top and bottom of the page.
368 387
369`$data` is an array containing: 388`$data` is an array containing:
370 389
371- `_LOGGEDIN_`: true if user is logged in, false otherwise. 390 - All templates data.
372- All templates data. 391 - [Special data](#special-data)
373 392
374##### Template placeholders 393##### Template placeholders
375 394
@@ -394,8 +413,8 @@ Allow to add content at the top and bottom of the page, the bottom of each link
394 413
395`$data` is an array containing: 414`$data` is an array containing:
396 415
397- `_LOGGEDIN_`: true if user is logged in, false otherwise. 416 - All templates data, including links.
398- All templates data, including links. 417 - [Special data](#special-data)
399 418
400##### Template placeholders 419##### Template placeholders
401 420
@@ -420,9 +439,8 @@ Allow to add tags in the feed, either in the header or for each items. Items (li
420 439
421`$data` is an array containing: 440`$data` is an array containing:
422 441
423- `_LOGGEDIN_`: true if user is logged in, false otherwise. 442 - All templates data, including links.
424- `_PAGE_`: containing either `rss` or `atom`. 443 - [Special data](#special-data)
425- All templates data, including links.
426 444
427##### Template placeholders 445##### Template placeholders
428 446
@@ -456,6 +474,8 @@ Allow to alter the link being saved in the datastore.
456- created 474- created
457- updated 475- updated
458 476
477Also [special data](#special-data).
478
459 479
460#### delete_link 480#### delete_link
461 481
@@ -465,7 +485,7 @@ Allow to execute any action before the link is actually removed from the datasto
465 485
466##### Data 486##### Data
467 487
468`$data` is an array containing the link being saved: 488`$data` is an array containing the link being deleted:
469 489
470- id 490- id
471- title 491- title
@@ -477,6 +497,7 @@ Allow to execute any action before the link is actually removed from the datasto
477- created 497- created
478- updated 498- updated
479 499
500Also [special data](#special-data).
480 501
481#### save_plugin_parameters 502#### save_plugin_parameters
482 503
@@ -492,6 +513,7 @@ For example it is used to update the CSS file of the `default_colors` plugins.
492So if the plugin has a parameter called `MYPLUGIN_PARAMETER`, 513So if the plugin has a parameter called `MYPLUGIN_PARAMETER`,
493the array will contain an entry with `MYPLUGIN_PARAMETER` as a key. 514the array will contain an entry with `MYPLUGIN_PARAMETER` as a key.
494 515
516Also [special data](#special-data).
495 517
496## Guide for template designer 518## Guide for template designer
497 519