Moving MyAlerts popup
#1
I've just recently started customising my MyAlerts popup proper, and I moved the location of the popup box from the default to my header.

I now notice that, although everything appears to be working fine, Alerts do not display. I did slightly edit the js file (couldn't get the dropdown to work without it):

Code:
jQuery.noConflict();

jQuery(document).ready(function($)
{
    $('body').on({
        click: function(event)
        {
            event.preventDefault();
            var popup_id = $(this).attr('id') + '_popup';

            $('#unreadAlerts_menu_popup').slideToggle('fast', function() {
                var toMarkRead = new Array;
                $('[id^="alert_row_popup_"]').each(function() {
                    toMarkRead.push($(this).attr('id').substr(16));
                });
(abridged, this is the only edited part)

My header template now looks like this:

Code:
<div id="unreadAlerts_menu_popup" class="myalerts_popup" style="display:none; color: black; text-align: left;">
        <div class="popupTitle"><h2 style="display: inline;">Alerts</h2></div>
        <ol>
        {$alerts}
        </ol>
        <div class="popupFooter"><a href="usercp.php?action=alerts" class="all_alerts" style="color: black;">All</a></div>
    </div>

{$welcomeblock}

{$pm_notice}
{$bannedwarning}
{$bbclosedwarning}
{$unreadreports}
{$pending_joinrequests}
(abridged)

The problem is, the alerts row (ie the content of myalerts_alert_row_popup) are not displaying. How can I get them to work?
Reply
#2
ANy chance I could get a link and test account to debug?
Reply
#3
PM sent. Happy
Reply
#4
Think I've found the issue. Around line #489 in inc/plugins/myalerts.php, try changing this line:

PHP Code:
global $templates$mybb$lang$myalerts_headericon$Alerts$plugins

to

PHP Code:
global $templates$mybb$lang$myalerts_headericon$Alerts$plugins$alerts

I'm not too sure it'll work because of the way the whole myalerts_pre_output_page() function works after everything else. You might have to add a new str_replace to the function if the above doesn't work.
Reply
#5
(22-04-2013, 11:22 AM)euan Wrote: Think I've found the issue. Around line #489 in inc/plugins/myalerts.php, try changing this line:

PHP Code:
global $templates$mybb$lang$myalerts_headericon$Alerts$plugins

to

PHP Code:
global $templates$mybb$lang$myalerts_headericon$Alerts$plugins$alerts

I'm not too sure it'll work because of the way the whole myalerts_pre_output_page() function works after everything else. You might have to add a new str_replace to the function if the above doesn't work.

Didn't work. What would the str_replace look like?
Reply
#6
Edit the template to replace {$alerts} with <alerts_here> or something. Then, at the end of the function myalerts_pre_output_page(&$contents) add this just after the other str_replace:

PHP Code:
$contents str_replace('<alerts_here>'$alerts$contents); 
Seabody likes this post
Reply
#7
Thanks Euan, that fixed it. Happy
euan likes this post
Reply
#8
Glad you got it sorted Happy I can't remember why exactly I had to use that hook, but I remember global_start causing all sorts of issues. Unfortunately it does make this level of customisation slightly more difficult to complete.
Reply