Called after tag conversion of HTML to bbcode (e.g. remote message posting)
`$b` is a string converted text
+### head
+Called when building the `<head>` sections.
+Stylesheets should be registered using this hook.
+`$b` is an HTML string of the `<head>` tag.
+
### page_header
Called after building the page navigation section.
`$b` is a string HTML of nav region.
### footer
Called after HTML content functions have completed.
+Deferred Javascript files should be registered using this hook.
`$b` is (string) HTML of footer div/element.
-Used to load deferred Javascript files.
### avatar_lookup
Called when looking up the avatar. `$b` is an array:
### src/App.php
Addon::callHooks('load_config');
+ Addon::callHooks('head');
Addon::callHooks('footer');
### src/Model/Item.php
public $force_max_items = 0;
public $theme_events_in_profile = true;
+ public $stylesheets = [];
public $footerScripts = [];
+ public function registerStylesheet($path)
+ {
+ $url = str_replace($this->get_basepath() . DIRECTORY_SEPARATOR, '', $path);
+
+ $this->stylesheets[] = trim($url, '/');
+ }
+
public function registerFooterScript($path)
{
$url = str_replace($this->get_basepath() . DIRECTORY_SEPARATOR, '', $path);
- $this->footerScripts[] = $this->get_baseurl() . '/' . trim($url, '/');
+ $this->footerScripts[] = trim($url, '/');
}
/**
$this->pager['start'] = ($this->pager['page'] * $this->pager['itemspage']) - $this->pager['itemspage'];
}
- public function init_pagehead()
+ public function initHead()
{
$interval = ((local_user()) ? PConfig::get(local_user(), 'system', 'update_interval') : 40000);
* since the code added by the modules frequently depends on it
* being first
*/
- if (!isset($this->page['htmlhead'])) {
- $this->page['htmlhead'] = '';
- }
// If we're using Smarty, then doing replace_macros() will replace
// any unrecognized variables with a blank string. Since we delay
}
// get data wich is needed for infinite scroll on the network page
- $invinite_scroll = infinite_scroll_data($this->module);
+ $infinite_scroll = infinite_scroll_data($this->module);
+
+ Core\Addon::callHooks('head', $this->page['htmlhead']);
$tpl = get_markup_template('head.tpl');
$this->page['htmlhead'] = replace_macros($tpl, [
'$shortcut_icon' => $shortcut_icon,
'$touch_icon' => $touch_icon,
'$stylesheet' => $stylesheet,
- '$infinite_scroll' => $invinite_scroll,
+ '$infinite_scroll' => $infinite_scroll,
'$block_public' => intval(Config::get('system', 'block_public')),
+ '$stylesheets' => $this->stylesheets,
]) . $this->page['htmlhead'];
}
Core\Addon::callHooks('footer', $this->page['footer']);
$tpl = get_markup_template('footer.tpl');
- $this->page['footer'] .= replace_macros($tpl, [
+ $this->page['footer'] = replace_macros($tpl, [
'$baseurl' => $this->get_baseurl(),
'$footerScripts' => $this->footerScripts,
- ]);
+ ]) . $this->page['footer'];
}
public function set_curl_code($code)