'target' => $template,
'loggedin' => $this->container->loginManager->isLoggedIn(),
'basePath' => $this->container->basePath,
+ 'rootPath' => preg_replace('#/index\.php$#', '', $this->container->basePath),
'bookmarkService' => $this->container->bookmarkService
];
}
'target' => '_PAGE_',
'loggedin' => '_LOGGEDIN_',
'basePath' => '_BASE_PATH_',
+ 'rootPath' => '_ROOT_PATH_',
'bookmarkService' => '_BOOKMARK_SERVICE_',
];
`PluginManager::$PLUGINS_PATH . '/mything/template.html'`.
If it needs to be included in front end side (e.g. an image),
-the relative path must be prefixed with special data `_BASE_PATH_`:
-`($data['_BASE_PATH_'] ?? '') . '/' . PluginManager::$PLUGINS_PATH . '/mything/picture.png`.
+the relative path must be prefixed with special data:
+
+ * if it's a link that will need to be processed by Shaarli, use `_BASE_PATH_`:
+ for e.g. `$data['_BASE_PATH_'] . '/admin/tools`.
+ * if you want to include an asset, you need to add the root URL (base path without `/index.php`, for people using Shaarli without URL rewriting), then use `_ROOT_PATH_`:
+ for e.g
+`$['_ROOT_PATH_'] . '/' . PluginManager::$PLUGINS_PATH . '/mything/picture.png`.
Note that special placeholders for CSS and JS files (respectively `css_files` and `js_files`) are already prefixed
-with the base path in template files.
+with the root path in template files.
### It's not working!
function hook_archiveorg_render_linklist($data)
{
$archive_html = file_get_contents(PluginManager::$PLUGINS_PATH . '/archiveorg/archiveorg.html');
- $rootPath = preg_replace('#/index\.php$#', '', $data['_BASE_PATH_'] ?? '');
- $path = $rootPath . '/' . PluginManager::$PLUGINS_PATH;
+ $path = ($data['_ROOT_PATH_'] ?? '') . '/' . PluginManager::$PLUGINS_PATH;
foreach ($data['links'] as &$value) {
$isNote = startsWith($value['real_url'], '/shaare/');
if ($conf->get('resource.theme') === 'default') {
$button .= '<i class="linklist-plugin-icon fa fa-comment"></i>';
} else {
- $button .= '<img class="linklist-plugin-icon" src="plugins/isso/comment.png" ';
+ $button .= '<img class="linklist-plugin-icon" src="'. $data['_ROOT_PATH_'].'/plugins/isso/comment.png" ';
$button .= 'title="Comment on this shaare" alt="Comments" />';
}
$button .= '</a></span>';
{
$qrcode_html = file_get_contents(PluginManager::$PLUGINS_PATH . '/qrcode/qrcode.html');
- $rootPath = preg_replace('#/index\.php$#', '', $data['_BASE_PATH_'] ?? '');
- $path = $rootPath . '/' . PluginManager::$PLUGINS_PATH;
+ $path = ($data['_ROOT_PATH_'] ?? '') . '/' . PluginManager::$PLUGINS_PATH;
foreach ($data['links'] as &$value) {
$qrcode = sprintf(
$qrcode_html,
$wallabagHtml = file_get_contents(PluginManager::$PLUGINS_PATH . '/wallabag/wallabag.html');
$linkTitle = t('Save to wallabag');
- $path = ($data['_BASE_PATH_'] ?? '') . '/' . PluginManager::$PLUGINS_PATH;
+ $path = ($data['_ROOT_PATH_'] ?? '') . '/' . PluginManager::$PLUGINS_PATH;
foreach ($data['links'] as &$value) {
$wallabag = sprintf(