Username in Templates...
3 posters
Page 1 of 1
Username in Templates...
Hey guys,
I have recently used a script from the French Support Forums: http://forum.forumactif.com/t260631-astuce-utiliser-les-variables-user-et-forum-autre
Now it's working, but only for staff. If the user is not in a staff user group. The name does not show up.
Here is the code that I'm using, it's in the index_body, just under the {JAVASCRIPT} variable.
And here is the javascript:
I have recently used a script from the French Support Forums: http://forum.forumactif.com/t260631-astuce-utiliser-les-variables-user-et-forum-autre
Now it's working, but only for staff. If the user is not in a staff user group. The name does not show up.
Here is the code that I'm using, it's in the index_body, just under the {JAVASCRIPT} variable.
- Code:
<div id="user_info">
<!-- BEGIN switch_user_logged_in -->
<div id="user_avatar" class="fl"><!-- avatar here --></div>
Welcome Back, <span class="USERNAME"></span> <br /><br />
<div id="add_links">
<ul>
<li><a href="{U_SEARCH_NEW}">{L_SEARCH_NEW}</a></li>
<li><a href="{U_SEARCH_SELF}">{L_SEARCH_SELF}</a></li>
<li><a href="{U_SEARCH_UNANSWERED}">{L_SEARCH_UNANSWERED}</a></li>
<li><a href="{U_MARK_READ}">{L_MARK_FORUMS_READ}</a></li>
</ul>
</div>
<!-- END switch_user_logged_in -->
<!-- BEGIN switch_user_logged_out -->
<p>Hello Guest,<br /> It appears that you are not logged in or that you have not registerd. You can Log-in or Register bellow!</p><br />
<a href="http://code-phase.forumotion.co.uk/login"> <img src="http://i43.servimg.com/u/f43/16/93/80/74/login10.png" alt="Log-In" /></a>
<a href="http://code-phase.forumotion.co.uk/register"> <img src="http://i43.servimg.com/u/f43/16/93/80/74/regist10.png" alt="Log-In" /></a>
<!-- END switch_user_logged_out -->
</div> <!-- end user_info -->
And here is the javascript:
- Code:
function treatvar(nom) {
var trouve = xhr.responseText.replace(RegExp("^.+<li style=\"margin-bottom:5px;direction:ltr;text-align:left;\"><strong>{" + nom + "}<\/strong> : (.*?) <span style='direction:ltr'>\(.*?\)<\/span><br \/><\/li>.+$"), '$1');
if (xhr.responseText == trouve) return;
var children = document.getElementsByTagName('*') || document.all;
var v = new Array();
var i = -1;
while (++i < children.length) {
var child = children[i];
var classNames = child.className.split(' ');
for (var j = 0; j < classNames.length; j++) {
if (classNames[j] == nom) {
v.push(child);
break;
}
}
}
i = -1;
while (++i != v.length) if (v[i].tagName == 'INPUT' || v[i].tagName == 'TEXTAREA') v[i].value += trouve;
else v[i].innerHTML += trouve;
};
if (window.ActiveXObject) {
var xhr = new ActiveXObject("Microsoft.XMLHTTP");
} else if (window.XMLHttpRequest) {
var xhr = new XMLHttpRequest();
}
if (xhr != null) {
xhr.onreadystatechange = function () {
if (xhr.readyState == 4) {
treatvar('FORUMURL');
treatvar('FORUMURLINK');
treatvar('FORUMNAME');
treatvar('FORUMNAMELINK');
treatvar('FORUMDESC');
treatvar('FORUMBIRTHDAY');
treatvar('FORUMAGE');
treatvar('FORUMCOUNTFORUM');
treatvar('FORUMCOUNTOPIC');
treatvar('FORUMCOUNTPOST');
treatvar('FORUMCOUNTUSER');
treatvar('FORUMONLINEUSER');
treatvar('FORUMONLINEDATE');
treatvar('FORUMLASTUSER');
treatvar('FORUMLASTUSERLINK');
treatvar('USERNAME');
treatvar('USERLINK');
treatvar('USERBIRTHDAY');
treatvar('USERAGE');
treatvar('USERREGDATE');
treatvar('USERLASTVISIT');
treatvar('USERCOUNTPOST');
}
};
xhr.open("GET", "/popup_help.forum?l=miscvars", true);
xhr.send(null);
}
Re: Username in Templates...
I don't know exactly, but... Try to create a invisible group, I mean Group status : Hidden group, Group auto-subscribe : Yes and Minimum Posts : 0. Something like Members +50
It's first thing appears in my mind.
It's first thing appears in my mind.
Guest- Guest
Re: Username in Templates...
Wait all that just to include the username in a template?
But its surely such an easy task, when I get back at my computer I'm gonna look into this. I can already think of a much easier way of doing this.
But its surely such an easy task, when I get back at my computer I'm gonna look into this. I can already think of a much easier way of doing this.
LGforum- Hyperactive
- Posts : 2265
Reputation : 264
Language : English
Location : UK
Re: Username in Templates...
Gassy wrote:I don't know exactly, but... Try to create a invisible group, I mean Group status : Hidden group, Group auto-subscribe : Yes and Minimum Posts : 0. Something like Members +50
It's first thing appears in my mind.
Already tried that
LGforum wrote:Wait all that just to include the username in a template?
But its surely such an easy task, when I get back at my computer I'm gonna look into this. I can already think of a much easier way of doing this.
OK, thanks
Re: Username in Templates...
Lol yes as i suspected it was much easier than i thought.
There was no need for Ajax requests at all.
So i only did it with the username variable since it seemed thats all you wanted but the same method can be used for all the other variables.
First put this:
Then put this into a javascript file:
Name it what you want.
and then in the templates wherever you want to put the username put:
Worked for me, so im guessing it should work for you.
There was no need for Ajax requests at all.
So i only did it with the username variable since it seemed thats all you wanted but the same method can be used for all the other variables.
First put this:
- Code:
<span id="username" style="display:none">{*USERNAME}</span>
Then put this into a javascript file:
- Code:
$(document).ready(function() {
var x=$('#username').html();
$('.templateuname').html(x);
});
Name it what you want.
and then in the templates wherever you want to put the username put:
- Code:
<span class="templateuname"></span>
Worked for me, so im guessing it should work for you.
LGforum- Hyperactive
- Posts : 2265
Reputation : 264
Language : English
Location : UK
Nera.- Energetic
- Posts : 7078
Reputation : 2017
Language : English
Location : -
Similar topics
» username on templates
» {*USERNAME} link in Templates...
» Error in templates?
» Templates
» How to use the templates?
» {*USERNAME} link in Templates...
» Error in templates?
» Templates
» How to use the templates?
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum