Code for number of unread PMs
3 posters
Page 1 of 1
Code for number of unread PMs
Greetings! I have my own custom NAV bar Live demo here and I was wondering if it was possible to put a piece of code that would return the number of messages a user has. Right now my NAV bar just says "Messages" but I want to make it say something like "Messages (2)" or something? Is that possible?
Best,
Ian
Best,
Ian
Last edited by ian2000 on April 13th 2015, 3:16 am; edited 1 time in total
Re: Code for number of unread PMs
Hey,
Did you delete {GENERATED_NAV_BAR} from the overall_header template ?
Did you delete {GENERATED_NAV_BAR} from the overall_header template ?
Re: Code for number of unread PMs
Ange Tuteur wrote:Hey,
Did you delete {GENERATED_NAV_BAR} from the overall_header template ?
Thank you for the quick reply. I did delete that {GENERATED_NAV_BAR} element. My nav bar is done completely manually.
Here is the code for my nav bar (inside overall_header)
- Spoiler:
- Code:
<div id="navbar">
<div class="wrapper">
<ul id="topnav">
<li id="button_home">
<a class="active firstlevel" href="http://onyxlegion.forumotion.net/forum#">
<span class="last firstlevel">Home</span>
</a>
</li>
<li id="button_demo">
<a class="firstlevel" href="/profile?change&mode=editprofile">
<span class="firstlevel">My Account</span>
</a>
<ul>
<li>
<a href="/privmsg?folder=inbox">
<span>Messages</span>
</a>
</li>
<li>
<a href="/groups">
<span>Membership Status</span>
</a>
</li>
<!--
<li>
<a href="http://onyxlegion.forumotion.net/forum#">
<span>Submenu Item 2...</span>
</a>
<ul>
<li>
<a href="http://onyxlegion.forumotion.net/forum#">
<span>Submenu Item 2.1</span>
</a>
</li>
<li>
<a href="http://onyxlegion.forumotion.net/forum#">
<span>Submenu Item 2.2</span>
</a>
</li>
<li>
<a href="http://onyxlegion.forumotion.net/forum#">
<span>Submenu Item 2.3</span>
</a>
</li>
</ul>
</li>
-->
</ul>
</li>
<li id="button_demo">
<a class="firstlevel" href="/memberlist">
<span class="firstlevel">Players</span>
</a>
</li>
<li id="button_demo">
<a class="firstlevel" href="/t39-technical-support-rules-and-faqs#104">
<span class="firstlevel">Support</span>
</a>
<ul>
<li>
<a href="/t7-what-is-onyx-legion-online">
<span>About</span>
</a>
</li>
<li>
<a href="/f3-in-game-discussion">
<span>Guides</span>
</a>
</li>
<!-- TEMP DISABLED
<li>
<a href="/t39-technical-support-rules-and-faqs#104">
<span>FAQs</span>
</a>
</li>
-->
<li>
<a href="/t39-technical-support-rules-and-faqs#104">
<span>Tech Support</span>
</a>
</li>
</ul>
</li>
<li id="button_demo">
<a class="firstlevel" href="/t49-voting-information#116">
<span class="firstlevel">Vote</span>
</a>
</li>
<!-- TEMP DISABLED
<li id="button_help">
<a class="firstlevel" href="DLOAD LINK">
<span class="firstlevel">Download</span>
</a>
</li>
-->
<li id="button_search">
<a class="firstlevel" href="/t45-what-are-jewels#111">
<span class="firstlevel">Get Jewels</span>
</a>
</li>
<!-- TEMP REMOVED
<li id="button_calendar">
<a class="firstlevel" href="http://onyxlegion.forumotion.net/forum#calendar">
<span class="firstlevel">Calendar</span>
</a>
</li>
-->
<li id="button_login">
<a class="firstlevel" href="http://onyxlegion.forumotion.net/forum#login">
<span class="firstlevel">Login</span>
</a>
</li>
<li id="button_register">
<a class="firstlevel" href="http://onyxlegion.forumotion.net/forum#register">
<span class="last firstlevel">Register</span>
</a>
</li>
</ul>
</div>
</div>
And just in case here is the entire code for overall_header
- Spoiler:
- Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" dir="{S_CONTENT_DIRECTION}" id="min-width" lang="{L_LANG_HTML}" xml:lang="{L_LANG_HTML}" {NAMESPACE_FB_LIKE} {NAMESPACE_FB} {NAMESPACE_BBCODE}>
<head>
<title>{SITENAME_TITLE}{PAGE_TITLE}</title>
<meta http-equiv="content-type" content="text/html; charset={S_CONTENT_ENCODING}" />
<meta http-equiv="content-script-type" content="text/javascript" />
<meta http-equiv="content-style-type" content="text/css" />
<!-- BEGIN switch_compat_meta -->
<meta http-equiv="X-UA-Compatible" content="IE={switch_compat_meta.VERSION}" />
<!-- END switch_compat_meta -->
<!-- BEGIN switch_canonical_url -->
<link rel="canonical" href="{switch_canonical_url.CANONICAL_URL}" />
<!-- END switch_canonical_url -->
{META_FAVICO}
{META}
{META_FB_LIKE}
<meta name="title" content="{SITENAME_TITLE}{PAGE_TITLE}" />
{T_HEAD_STYLESHEET}
{CSS}
<link rel="search" type="application/opensearchdescription+xml" href="/improvedsearch.xml" title="{SITENAME}" />
<link rel="search" type="application/opensearchdescription+xml" href="{URL_BOARD_DIRECTORY}/search/improvedsearch.xml" title="{SEARCH_FORUMS}" />
<script src="{JQUERY_PATH}" type="text/javascript"></script>
<script src="{JS_DIR}{L_LANG}.js" type="text/javascript"></script>
<!-- BEGIN switch_fb_login -->
<script src="http://connect.facebook.net/{switch_fb_login.FB_LOCAL}/all.js" type="text/javascript"></script>
<script src="{switch_fb_login.JS_FB_LOGIN}" type="text/javascript"></script>
<!-- END switch_fb_login -->
<!-- BEGIN switch_ticker -->
<link type="text/css" rel="stylesheet" href="{JS_DIR}jquery/ticker/ticker.css" />
<script src="{JS_DIR}jquery/ticker/ticker.js" type="text/javascript"></script>
<!-- END switch_ticker -->
<!-- BEGIN switch_ticker_new -->
<script src="{JS_DIR}jquery/jcarousel/jquery.jcarousel.js" type="text/javascript"></script>
<script type="text/javascript">//<![CDATA[
/* Definir le sens de direction en fonction du panneau admin */
var tickerDirParam = "{switch_ticker.DIRECTION}";
var slid_vert = false;
var auto_dir = 'next';
var h_perso = parseInt({switch_ticker.HEIGHT});
switch( tickerDirParam )
{
case 'top' :
slid_vert = true;
break;
case 'left':
break;
case 'bottom':
slid_vert = true;
auto_dir = 'prev';
break;
case 'right':
auto_dir = 'prev';
break;
default:
slid_vert = true;
}
$(document).ready(function() {
var width_max = $('ul#fa_ticker_content').width();
var width_item = Math.floor(width_max / {switch_ticker.SIZE});
if (width_max > 0)
{
$('#fa_ticker_content').css('display','block');
$('ul#fa_ticker_content li').css('float','left').css('list-style','none').width(width_item).find('img').each(function () {
if ($(this).width() > width_item)
{
var ratio = $(this).width() / width_item;
var new_height = Math.round($(this).height() / ratio);
$(this).height(new_height).width(width_item);
}
});
if (slid_vert)
{
var height_max = h_perso;
$('ul#fa_ticker_content li').each( function () {
if ($(this).height() > height_max)
{
height_max = $(this).height();
}
} );
$('ul#fa_ticker_content').width(width_item).height(height_max).css('marginLeft','auto').css('marginRight','auto');
$('ul#fa_ticker_content li').height(height_max);
}
$('#fa_ticker_content').jcarousel({
vertical: slid_vert,
wrap: 'circular',
auto: {switch_ticker.STOP_TIME},
auto_direction: auto_dir,
scroll: 1,
size: {switch_ticker.SIZE},
height_max: height_max,
animation: {switch_ticker.SPEED}
});
}
else
{
$('ul#fa_ticker_content li:not(:first)').css('display','none');
$('ul#fa_ticker_content li:first').css('list-style','none').css('text-align','center');
}
});
//]]>
</script>
<!-- END switch_ticker_new -->
<script type="text/javascript">
//<![CDATA[
$(document).ready(function(){
<!-- BEGIN switch_enable_pm_popup -->
pm = window.open('{U_PRIVATEMSGS_POPUP}', '_faprivmsg', 'HEIGHT=225,resizable=yes,WIDTH=400');
if(pm != null) { pm.focus(); }
<!-- END switch_enable_pm_popup -->
<!-- BEGIN switch_report_popup -->
report = window.open('{switch_report_popup.U_REPORT_POPUP}', '_phpbbreport', 'HEIGHT={switch_report_popup.S_HEIGHT},resizable=yes,scrollbars=no,WIDTH={switch_report_popup.S_WIDTH}');
if(report != null) { report.focus(); }
<!-- END switch_report_popup -->
<!-- BEGIN switch_ticker -->
ticker_start({switch_ticker.HEIGHT}, {switch_ticker.SPACING}, {switch_ticker.SPEED}, '{switch_ticker.DIRECTION}', {switch_ticker.STOP_TIME});
<!-- END switch_ticker -->
});
<!-- BEGIN switch_login_popup -->
var logInPopUpLeft, logInPopUpTop, logInPopUpWidth = {LOGIN_POPUP_WIDTH}, logInPopUpHeight = {LOGIN_POPUP_HEIGHT}, logInBackgroundResize = false, logInBackgroundClass = false;
<!-- END switch_login_popup -->
<!-- BEGIN switch_login_popup -->
$(document).ready( function() {
$(window).resize(function() {
var windowWidth = document.documentElement.clientWidth;
var popupWidth = $("#login_popup").width();
var mypopup = $("#login_popup");
$("#login_popup").css({
"left": windowWidth/2 - popupWidth/2
});
});
});
<!-- END switch_login_popup -->
//]]>
</script>
{GREETING_POPUP}
<!-- BEGIN switch_ticker_new -->
<style>
.jcarousel-skin-tango .jcarousel-item {
text-align:center;
width: 10px;
}
.jcarousel-skin-tango .jcarousel-item-horizontal {
margin-right: {switch_ticker.SPACING}px;
}
.jcarousel-skin-tango .jcarousel-item-vertical {
margin-bottom: {switch_ticker.SPACING}px;
}
</style>
<!-- END switch_ticker_new -->
{HOSTING_JS}
<!-- BEGIN google_analytics_code -->
<script type="text/javascript">
//<![CDATA[
var _gaq = _gaq || [];
_gaq.push(["_setAccount", "{G_ANALYTICS_ID}"]);
_gaq.push(["_trackPageview"]);
_gaq.push(['_trackPageLoadTime']);
<!-- BEGIN google_analytics_code_bis -->
_gaq.push(['b._setAccount', '{G_ANALYTICS_ID_BIS}']);
_gaq.push(['b._trackPageview']);
<!-- END google_analytics_code_bis -->
(function() {
var ga = document.createElement("script"); ga.type = "text/javascript"; ga.async = true;
ga.src = ("https:" == document.location.protocol ? "https://ssl" : "http://www") + ".google-analytics.com/ga.js";
var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(ga, s);
})();
//]]>
</script>
<!-- END google_analytics_code -->
</head>
<body>
<!-- BEGIN hitskin_preview -->
<div id="hitskin_preview" style="display: block;">
<h1><img src="http://2img.net/i/fa/hitskin/hitskin_logo.png" alt="" /> Hit<em>skin</em>.com</h1>
<div class="content">
<p>
{hitskin_preview.L_THEME_SITE_PREVIEW}
<br />
<span>{hitskin_preview.U_INSTALL_THEME}<a href="http://{hitskin_preview.U_RETURN_THEME}">{hitskin_preview.L_RETURN_THEME}</a></span>
</p>
</div>
</div>
<!-- END hitskin_preview -->
<!-- BEGIN switch_login_popup -->
<div id="login_popup" class="module main">
<div id="login_popup_title" class="main-head">
<div class="h3">{SITENAME}</div>
</div>
<div class="main-content">
{LOGIN_POPUP_MSG}
<div id="login_popup_buttons">
<form action="{S_LOGIN_ACTION}" method="get">
<input type="submit" class="button2" value="{L_LOGIN}" />
<input type="button" class="button2" value="{L_REGISTER}" onclick="parent.location='{U_REGISTER}';" />
<input id="login_popup_close" type="button" class="button2" value="{L_DONT_DISPLAY_AGAIN}" />
</form>
</div>
</div>
</div>
<!-- END switch_login_popup -->
<a id="top" name="top" accesskey="t"></a>
<div class="minwidth_IE">
<div class="layout_IE">
<div class="container_IE">
<div class="pun">
<div id="header">
<div class="wrapper">
<a id="logo" href="http://onyxlegion.forumotion.net/forum#"></a>
<!--
<div id="search">
<form action="http://onyxlegion.forumotion.net/forum#search" method="post" accept-charset="ISO-8859-1">
<!--SEARCH FIELD DISABLED
<input class="search-input" type="text" name="search" value="Search..." onfocus="this.value = '';" onblur="if(this.value=='') this.value='Search...';" />
<input class="search-button" type="submit" name="submit" value="" />
</form>
</div>
-->
</div>
</div>
<div id="navbar">
<div class="wrapper">
<ul id="topnav">
<li id="button_home">
<a class="active firstlevel" href="http://onyxlegion.forumotion.net/forum#">
<span class="last firstlevel">Home</span>
</a>
</li>
<li id="button_demo">
<a class="firstlevel" href="/profile?change&mode=editprofile">
<span class="firstlevel">My Account</span>
</a>
<ul>
<li>
<a href="/privmsg?folder=inbox">
<span>Messages</span>
</a>
</li>
<li>
<a href="/groups">
<span>Membership Status</span>
</a>
</li>
<!--
<li>
<a href="http://onyxlegion.forumotion.net/forum#">
<span>Submenu Item 2...</span>
</a>
<ul>
<li>
<a href="http://onyxlegion.forumotion.net/forum#">
<span>Submenu Item 2.1</span>
</a>
</li>
<li>
<a href="http://onyxlegion.forumotion.net/forum#">
<span>Submenu Item 2.2</span>
</a>
</li>
<li>
<a href="http://onyxlegion.forumotion.net/forum#">
<span>Submenu Item 2.3</span>
</a>
</li>
</ul>
</li>
-->
</ul>
</li>
<li id="button_demo">
<a class="firstlevel" href="/memberlist">
<span class="firstlevel">Players</span>
</a>
</li>
<li id="button_demo">
<a class="firstlevel" href="/t39-technical-support-rules-and-faqs#104">
<span class="firstlevel">Support</span>
</a>
<ul>
<li>
<a href="/t7-what-is-onyx-legion-online">
<span>About</span>
</a>
</li>
<li>
<a href="/f3-in-game-discussion">
<span>Guides</span>
</a>
</li>
<!-- TEMP DISABLED
<li>
<a href="/t39-technical-support-rules-and-faqs#104">
<span>FAQs</span>
</a>
</li>
-->
<li>
<a href="/t39-technical-support-rules-and-faqs#104">
<span>Tech Support</span>
</a>
</li>
</ul>
</li>
<li id="button_demo">
<a class="firstlevel" href="/t49-voting-information#116">
<span class="firstlevel">Vote</span>
</a>
</li>
<!-- TEMP DISABLED
<li id="button_help">
<a class="firstlevel" href="DLOAD LINK">
<span class="firstlevel">Download</span>
</a>
</li>
-->
<li id="button_search">
<a class="firstlevel" href="/t45-what-are-jewels#111">
<span class="firstlevel">Get Jewels</span>
</a>
</li>
<!-- TEMP REMOVED
<li id="button_calendar">
<a class="firstlevel" href="http://onyxlegion.forumotion.net/forum#calendar">
<span class="firstlevel">Calendar</span>
</a>
</li>
-->
<li id="button_login">
<a class="firstlevel" href="http://onyxlegion.forumotion.net/forum#login">
<span class="firstlevel">Login</span>
</a>
</li>
<li id="button_register">
<a class="firstlevel" href="http://onyxlegion.forumotion.net/forum#register">
<span class="last firstlevel">Register</span>
</a>
</li>
</ul>
</div>
</div>
<div class="wrapper">
<div id="board-notice">
</div>
<div id="content-wrapper">
<div id="toolbar">
<div id="quicknav">
<ul>
<li class="facebook social"><a href="#" title="Facebook" target="_blank"></a></li>
<li class="twitter social"><a href="#" title="Twitter" target="_blank"></a></li>
<!--<li class="googleplus social"><a href="#" title="Google+" target="_blank"></a></li>-->
<li class="youtube social"><a href="#" title="Youtube" target="_blank"></a></li>
<!--<li class="pinterest social"><a href="#" title="Pinterest" target="_blank"></a></li>-->
</ul>
</div>
<div id="account">
<!-- REMOVE FOR NOW (LOGINSHIT)
<form id="guest_form" action="http://onyxlegion.forumotion.net/forum#login" method="post" accept-charset="ISO-8859-1" onsubmit="hashLoginPassword(this, 'b5086172df117885f0a2d02426a4916e');">
<input class="login-id" type="text" name="user" onfocus="if(this.value=='Username')value='';" onblur="if(this.value=='')value='Username';" value="Username" />
<input class="login-pw" type="password" name="password" onfocus="if(this.value=='Password')value='';" onblur="if(this.value=='')value='Password';" value="Password" />
<input class="login-btn" type="submit" value="" title="Login" />
<a class="signup-btn" title="Register" value="{L_REGISTER}" onclick="parent.location='{U_REGISTER}';"></a>
<input type="hidden" name="hash_password" value="" />
<a class="login-btn" title="Login" type="submit" value="" onclick="parent.location='login?connexion';"></a>-->
<input class="login-btn" type="submit" value="" title="Login" onclick="parent.location='login?connexion';" />
<a class="signup-btn" title="Register" value="{L_REGISTER}" onclick="parent.location='{U_REGISTER}';"></a>
</form>
</div>
</div>
<!-- BEGIN switch_ticker_new -->
<div id="fa_ticker_block" style="padding-top:4px;">
<div class="module main">
<div class="main-content clearfix">
<div id="fa_ticker_container">
<ul id="fa_ticker_content" class="jcarousel-skin-tango" style="display: none;width: 100%;">
<!-- BEGIN ticker_row -->
<li>{switch_ticker.ticker_row.ELEMENT}</li>
<!-- END ticker_row -->
</ul>
</div>
</div>
</div>
</div>
<!-- END switch_ticker_new -->
<!-- BEGIN switch_ticker -->
<div id="fa_ticker_block" style="padding-top:4px;">
<div class="module main">
<div class="main-content clearfix">
<div id="fa_ticker_container">
<div id="fa_ticker" style="height:{switch_ticker.HEIGHT}px;">
<div class="fa_ticker_content">
<!-- BEGIN ticker_row -->
<div>{switch_ticker.ticker_row.ELEMENT}</div>
<!-- END ticker_row -->
</div>
</div>
</div>
</div>
</div>
</div>
<!-- END switch_ticker -->
<div id="page-body">
<div id="{ID_CONTENT_CONTAINER}"{CLASS_CONTENT_CONTAINER}>
<div id="outer-wrapper">
<div id="wrapper">
<div id="container">
<div id="content">
<div id="{ID_LEFT}">
<!-- BEGIN giefmod_index1 -->
{giefmod_index1.MODVAR}
<!-- BEGIN saut -->
<div style="height:{SPACE_ROW}px"></div>
<!-- END saut -->
<!-- END giefmod_index1 -->
</div>
<div id="main">
<div id="main-content">
<!-- BEGIN html_validation -->
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</body>
</html>
<!-- END html_validation -->
Re: Code for number of unread PMs
The original navbar would need to be available so we can check the message link innerHTML. Add this to the template :
- Code:
<div id="fa_navbar" style="display:none">{GENERATED_NAV_BAR}</div>
Re: Code for number of unread PMs
Okay I added that and positioned it right above the code for my navbar. Is the code for accessing the innerHTML something I can have help with?
Thanks,
Ian
Thanks,
Ian
Re: Code for number of unread PMs
Fixed it!
With no messages:
With one new messge:
With no messages:
With one new messge:
- Code:
<li id="button_demo">
<a class="firstlevel" href="/profile?change&mode=editprofile">
<span class="firstlevel">My Account<b id='mainAcc'></b></span>
</a>
<ul>
<!--i_icon_mini_new_message-->
<li>
<a href="/privmsg?folder=inbox">
<span>Messages <b id='boldStuff'>(none)</b></span>
<script type="text/javascript">
function changeText(){
var messageString = document.getElementById('i_icon_mini_new_message').getAttribute('alt');
var messageArray = messageString.split(" ");
var messageNumber = (messageArray[2] != "") ? messageArray[2] : "0";
if (messageArray[2] != "") {
document.getElementById('mainAcc').innerHTML = " (!)";
}
document.getElementById('boldStuff').innerHTML = " (" + messageNumber + ")";
}
changeText();
</script>
</a>
</li>
Re: Code for number of unread PMs
Thanks for posting the solution.
Topic solved and archived
Topic solved and archived
Lost Founder's Password |Forum's Utilities |Report a Forum |General Rules |FAQ |Tricks & Tips
You need one post to send a PM.
You need one post to send a PM.
When your topic has been solved, ensure you mark the topic solved.
Never post your email in public.
Similar topics
» Unread notification breaks code (AWESOMEBB)
» When i paste a long code via [code][/code] the page expands
» New Select Code with line number!
» Keep UNread posts UNread!
» The number of topics does not match the number of articles
» When i paste a long code via [code][/code] the page expands
» New Select Code with line number!
» Keep UNread posts UNread!
» The number of topics does not match the number of articles
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum