Rocker92 at 17h58
07
Nov
2011
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);
}
1 Guest, on 07/11/2011 at 18h07
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.
2 LGforum, on 07/11/2011 at 18h13
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.
3 Rocker92, on 07/11/2011 at 18h24
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
4 LGforum, on 07/11/2011 at 19h12
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:
Into somewhere where you can put HTML, i put it in the forum description box. (obviously remove the * )
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:
You can put this in as many places as you want in the template.
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>
Into somewhere where you can put HTML, i put it in the forum description box. (obviously remove the * )
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>
You can put this in as many places as you want in the template.
Worked for me, so im guessing it should work for you.
5 Rocker92, on 07/11/2011 at 20h09
Thanks mate
Solved
Solved
6 Nera., on 08/11/2011 at 19h04
Lock
Similar topics
On PunBB, what code is it, so that i can add, Code:Welcome { USERNAME }
I know that Code:{ USERNAME } works, but i doesn't work outside, the posts... e.g. in the overall_Header, it didnt seem to be working.
any suggestions, on
What's the best username you ever heard? It can be yours or someone elses.
In my opinion, it's HaZe
UH, am i allowed to change username?
Replies 1 to 6 on 6 for "Username in Templates..."
Search
Informations
6 Replies For the topic :
"Username in Templates..."
This topic has been viewed 748 times.
Last message :
07/11/2011 at 17h58 by "Rocker92"





