PDA

View Full Version : Conditional Help


UKBusinessLive
03-25-2009, 06:22 PM
Hi guys ;)

I need a little help and i hope that one of you guys can help me here

i'm using the conditional below, in my header

<if condition="$bbuserinfo['usergroupid'] == x">
<meta HTTP-EQUIV="REFRESH" content="0; url=http://www.ukbusinesslive.co.uk/warning.html">
</if>

But the problem is that, it keeps repeating, the HTML code i wrote has a redirect back to the forum URL, But by using the above it keeps repeating in a loop :(

Is there a way to make a conditional run once and then end??

Thanks in advance

Gerry ;)

TigerC10
03-26-2009, 12:30 PM
Try:


<if condition="THIS_SCRIPT != "index" && $bbuserinfo['usergroupid'] == x">
<meta HTTP-EQUIV="REFRESH" content="0; url=http://www.ukbusinesslive.co.uk/warning.html">
</if>

UKBusinessLive
03-26-2009, 06:56 PM
Try:


<if condition="THIS_SCRIPT != "index" && $bbuserinfo['usergroupid'] == x">
<meta HTTP-EQUIV="REFRESH" content="0; url=http://www.ukbusinesslive.co.uk/warning.html">
</if>


Thanks Tiger, will give it a shot ;)

Lynne
03-26-2009, 07:00 PM
Are you saying when you get redirected to http://www.ukbusinesslive.co.uk/warning.html then it keeps repeating?

UKBusinessLive
03-27-2009, 06:10 AM
Are you saying when you get redirected to http://www.ukbusinesslive.co.uk/warning.html then it keeps repeating?

hi Lynne,

Firstly the above url is only an example ;) its not working,

What i've done is written a piece of code which re-directs back to the forum upon completion, But to get someone to go to that code when they type the forums url i used this conditional

<if condition="$bbuserinfo['usergroupid'] == x">
<meta HTTP-EQUIV="REFRESH" content="0; url=http://www.ukbusinesslive.co.uk/warning.html">
</if>

But, thats not gonna work as it will divert to the warning.html, then goes to the forum url, before starting all over again :o

is there a way that the above conditional can be changed, so that it onlt works the once??

The only other way would be with some form of cookie control using javascript, like the code below??


var expDays = 1; How long the cookie lasts for

var page = "warning.html";
var windowprops = "width=100%,height=100%,location=no,toolbar=no,menu bar=no,scrollbars=no,resizable=yes";

function GetCookie (name) {
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while (i < clen) {
var j = i + alen;
if (document.cookie.substring(i, j) == arg)
return getCookieVal (j);
i = document.cookie.indexOf(" ", i) + 1;
if (i == 0) break;
}
return null;
}
function SetCookie (name, value) {
var argv = SetCookie.arguments;
var argc = SetCookie.arguments.length;
var expires = (argc > 2) ? argv[2] : null;
var path = (argc > 3) ? argv[3] : null;
var domain = (argc > 4) ? argv[4] : null;
var secure = (argc > 5) ? argv[5] : false;
document.cookie = name + "=" + escape (value) +
((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
((path == null) ? "" : ("; path=" + path)) +
((domain == null) ? "" : ("; domain=" + domain)) +
((secure == true) ? "; secure" : "");
}
function DeleteCookie (name) {
var exp = new Date();
exp.setTime (exp.getTime() - 1);
var cval = GetCookie (name);
document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}
var exp = new Date();
exp.setTime(exp.getTime() + (expDays*24*60*60*1000));
function amt(){
var count = GetCookie('count')
if(count == null) {
SetCookie('count','1')
return 1
}
else {
var newcount = parseInt(count) + 1;
DeleteCookie('count')
SetCookie('count',newcount,exp)
return count
}
}
function getCookieVal(offset) {
var endstr = document.cookie.indexOf (";", offset);
if (endstr == -1)
endstr = document.cookie.length;
return unescape(document.cookie.substring(offset, endstr));
}

function checkCount() {
var count = GetCookie('count');
if (count == null) {
count=1;
SetCookie('count', count, exp);

window.open(page, "", windowprops);

}
else {
count++;
SetCookie('count', count, exp);
}
}
// End -->
</script>

Any have any other ides??

Lynne
03-27-2009, 02:32 PM
Why don't you have the redirect pass a variable and if that variable exists then don't redirect anymore?

User gets redirected to http://www.ukbusinesslive.co.uk/warning.html and then when that is done, they get sent back to index.php except the url would be index.php?myscript=done. And then on the page, if $_GET[myscript] == done, don't redirect again?

A cookie would work also (as you said). Look in the API to see about a function to set cookies using vB.