2020-05-15, 07:54 AM
2020-05-15, 09:16 AM
global_start
if you want to catch any page2020-05-15, 10:15 AM
(2020-05-15, 09:16 AM)Crazycat Wrote: [ -> ]global_start
if you want to catch any page
hey thx
how bout
pre_output_page
2020-05-15, 10:58 AM
Do you need to do modifications on the page content with your plugin ? If no, you'd better choose one of the
global_*
hooks.2020-05-15, 12:41 PM
(2020-05-15, 10:58 AM)Crazycat Wrote: [ -> ]Do you need to do modifications on the page content with your plugin ? If no, you'd better choose one of the global_*
hooks.
yea want to inform the user that they have been given award
thx!
2020-05-15, 03:53 PM
use
Here is what I do in ABP User Map to warn user if they don't fill their localisation:
global_intermediate
hook to fill the template you'll add.Here is what I do in ABP User Map to warn user if they don't fill their localisation:
$plugins->add_hook('global_intermediate', 'abp_umap_toplink');
function abp_umap_toplink() {
global $mybb, $templates, $templatelist, $lang, $abp_umap_warnuser, $current_page;
$warnpage = ['index.php', 'showthread.php', 'forumdisplay.php', 'newthread.php', 'newreply.php', 'polls.php', 'search.php'];
$lang->load(CN_ABPUMAP);
if ((int)$mybb->user['uid']>0
&& in_array($current_page, $warnpage)
&& $mybb->settings[CN_ABPUMAP.'_warnuser']==1
&& !$mybb->user['islocalised']) {
$abp_umap_warningnotset = $lang->sprintf($lang->abp_umap_warningnotset, $mybb->settings['bburl']);
eval("\$" . CN_ABPUMAP ."_warnuser =\"" . $templates->get(UMAP_TPL . '_warnuser') . "\";");
} else {
eval("\$" . CN_ABPUMAP ."_warnuser =\"\";");
}
}
the warnuser template is added at the end of header template:find_replace_templatesets("header", "#" . preg_quote('<br />'). "$#i", '<br />{$' . CN_ABPUMAP . '_warnuser}');
2020-05-15, 04:36 PM
(2020-05-15, 03:53 PM)Crazycat Wrote: [ -> ]useglobal_intermediate
hook to fill the template you'll add.
Here is what I do in ABP User Map to warn user if they don't fill their localisation:
the warnuser template is added at the end of header template:$plugins->add_hook('global_intermediate', 'abp_umap_toplink'); function abp_umap_toplink() { global $mybb, $templates, $templatelist, $lang, $abp_umap_warnuser, $current_page; $warnpage = ['index.php', 'showthread.php', 'forumdisplay.php', 'newthread.php', 'newreply.php', 'polls.php', 'search.php']; $lang->load(CN_ABPUMAP); if ((int)$mybb->user['uid']>0 && in_array($current_page, $warnpage) && $mybb->settings[CN_ABPUMAP.'_warnuser']==1 && !$mybb->user['islocalised']) { $abp_umap_warningnotset = $lang->sprintf($lang->abp_umap_warningnotset, $mybb->settings['bburl']); eval("\$" . CN_ABPUMAP ."_warnuser =\"" . $templates->get(UMAP_TPL . '_warnuser') . "\";"); } else { eval("\$" . CN_ABPUMAP ."_warnuser =\"\";"); } }
find_replace_templatesets("header", "#" . preg_quote('<br />'). "$#i", '<br />{$' . CN_ABPUMAP . '_warnuser}');
thx for the answer but just wondering if its bad to use pre_output_page?
cuz i have some plugins that uses that to do modifications on the page content
2020-05-15, 06:39 PM
I suppose you could use
pre_output_page
, but it isn’t called in as many pages as global_start
(i.e: some popup windows).2020-05-15, 10:10 PM
And as I said before:
pre_output_page
is used to modify the page content before its display (as example to hide all links for guest with a preg_replace)2020-05-16, 04:30 PM
(2020-05-15, 06:39 PM)Omar G. Wrote: [ -> ]I suppose you could usepre_output_page
, but it isn’t called in as many pages asglobal_start
(i.e: some popup windows).
(2020-05-15, 10:10 PM)Crazycat Wrote: [ -> ]And as I said before: pre_output_page
is used to modify the page content before its display (as example to hide all links for guest with a preg_replace)
thx for the reply