Thread Rating:
  • 3 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Dismiss Moderator Notice
#1
Purpose:
Add a dismiss button in Moderator Notice : Report Alert same as default PM notice has which will make the notice hidden once dismissed until a new report occurs.

Dependency:
1. jQuery Library
2. jQuery Cookie Plugin

Method:
1. Go to your headerinclude template and include the jQuery library (if not already included) and jQuery Cookie plugin. find the code {$stylesheets} and add the following just before that:

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"></script>
<script type="text/javascript">
if (typeof jQuery == 'undefined') {
    document.write(unescape("%3Cscript src='http://demonate.net/CDN/Library/jquery-1.8.2.min.js' type='text/javascript'%3E%3C/script%3E"));
}
</script>
<script type="text/javascript">jQuery.noConflict();</script>
<script type="text/javascript" src="http://demonate.net/CDN/Library/jquery.cookie.js"></script>

2. Now in the same template (headerinclude) find this line:
{$newpmmsg}

add just before that:
<script type="text/javascript">
jQuery(document).ready(function(){

	// Hide the notice if already dismissed; based on cookie value
	if (jQuery.cookie("report_notice") == "{$reported['unread']}") { jQuery("#report_notice").hide();}

	// Define the function of dismiss button
	jQuery('#dismiss').click(function() {
		dsms_trgt = jQuery(this).parent().parent().attr("id");
		dsms_val = jQuery(this).parent().parent().attr("count");
        jQuery.cookie(dsms_trgt, dsms_val, { expires: 365 });
		jQuery(this).parent().parent().hide();
		return false; 
	});

});
</script>

Save the modified 'headerinclude'.

3. Now, go to Global Templates > global_unreadreports and add the blue bold texts just as shown below (or, simply replace the entire content with the following code chunk):

<div class="red_alert" id="report_notice" count="{$reported['unread']}"><div class="float_right"><a href="#" id="dismiss" title="{$lang->dismiss_notice}"><img src="{$theme['imgdir']}/dismiss_notice.gif" alt="{$lang->dismiss_notice}" /></a></div><a href="modcp.php?action=reports">{$lang->unread_reports}</a></div>
<br />

Save the template.

Congratz!!! You have successfully enabled dismiss button for Moderator Notice. Big Grin

[Image: CHen36S.png]

Happy coding ...
[Image: logo.svg.svg]
Reply
#2
Thanks!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)