Called after HTML content functions have completed.
`$b` is (string) HTML of content div.
+### footer
+Called after HTML content functions have completed.
+`$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('footer');
### src/Model/Item.php
header('X-Account-Management-Status: none');
}
-/* set up page['htmlhead'] and page['end'] for the modules to use */
-$a->page['htmlhead'] = '';
-$a->page['end'] = '';
-
$_SESSION['sysmsg'] = defaults($_SESSION, 'sysmsg' , []);
$_SESSION['sysmsg_info'] = defaults($_SESSION, 'sysmsg_info' , []);
$_SESSION['last_updated'] = defaults($_SESSION, 'last_updated', []);
/* initialise content region */
-if (! x($a->page, 'content')) {
- $a->page['content'] = '';
-}
-
if ($a->mode == App::MODE_NORMAL) {
Addon::callHooks('page_content_top', $a->page['content']);
}
* Build the page ending -- this is stuff that goes right before
* the closing </body> tag
*/
-$a->init_page_end();
-
-// If you're just visiting, let javascript take you home
-if (x($_SESSION, 'visitor_home')) {
- $homebase = $_SESSION['visitor_home'];
-} elseif (local_user()) {
- $homebase = 'profile/' . $a->user['nickname'];
-}
-
-if (isset($homebase)) {
- $a->page['content'] .= '<script>var homebase="' . $homebase . '" ; </script>';
-}
+$a->initFooter();
/*
* now that we've been through the module content, see if the page reported
Nav::build($a);
}
-/*
- * Add a "toggle mobile" link if we're using a mobile device
- */
-if ($a->is_mobile || $a->is_tablet) {
- if (isset($_SESSION['show-mobile']) && !$_SESSION['show-mobile']) {
- $link = 'toggle_mobile?address=' . curPageURL();
- } else {
- $link = 'toggle_mobile?off=1&address=' . curPageURL();
- }
- $a->page['footer'] = replace_macros(
- get_markup_template("toggle_mobile_footer.tpl"),
- [
- '$toggle_link' => $link,
- '$toggle_text' => L10n::t('toggle mobile')]
- );
-}
-
/**
* Build the page - now that we have all the components
*/
public $force_max_items = 0;
public $theme_events_in_profile = true;
+ public $footerScripts = [];
+
+ public function registerFooterScript($path)
+ {
+ $url = str_replace($this->get_basepath() . DIRECTORY_SEPARATOR, '', $path);
+
+ $this->footerScripts[] = $this->get_baseurl() . '/' . trim($url, '/');
+ }
+
/**
* @brief An array for all theme-controllable parameters
*
]) . $this->page['htmlhead'];
}
- public function init_page_end()
+ public function initFooter()
{
- if (!isset($this->page['end'])) {
- $this->page['end'] = '';
+ if (!isset($this->page['footer'])) {
+ $this->page['footer'] = '';
+ }
+
+ // If you're just visiting, let javascript take you home
+ if (!empty($_SESSION['visitor_home'])) {
+ $homebase = $_SESSION['visitor_home'];
+ } elseif (local_user()) {
+ $homebase = 'profile/' . $a->user['nickname'];
+ }
+
+ if (isset($homebase)) {
+ $this->page['footer'] .= '<script>var homebase="' . $homebase . '";</script>' . "\n";
}
- $tpl = get_markup_template('end.tpl');
- $this->page['end'] = replace_macros($tpl, [
- '$baseurl' => $this->get_baseurl()
- ]) . $this->page['end'];
+
+ /*
+ * Add a "toggle mobile" link if we're using a mobile device
+ */
+ if ($this->is_mobile || $this->is_tablet) {
+ if (isset($_SESSION['show-mobile']) && !$_SESSION['show-mobile']) {
+ $link = 'toggle_mobile?address=' . curPageURL();
+ } else {
+ $link = 'toggle_mobile?off=1&address=' . curPageURL();
+ }
+ $this->page['footer'] .= replace_macros(get_markup_template("toggle_mobile_footer.tpl"), [
+ '$toggle_link' => $link,
+ '$toggle_text' => Core\L10n::t('toggle mobile')
+ ]);
+ }
+
+ Core\Addon::callHooks('footer', $this->page['footer']);
+
+ $tpl = get_markup_template('footer.tpl');
+ $this->page['footer'] .= replace_macros($tpl, [
+ '$baseurl' => $this->get_baseurl(),
+ '$footerScripts' => $this->footerScripts,
+ ]);
}
public function set_curl_code($code)
--- /dev/null
+{{foreach $footerScripts as $scriptUrl}}
+<script type="text/javascript" src="{{$scriptUrl}}"></script>
+{{/foreach}}