Log in

View Full Version : if condition depending on url or address


Super Jinni
01-18-2009, 08:44 AM
Hi everyone,
I'm wondering if there is anyway to set an if condition depending on page url or address and on the last part of url, like:

when user go to usercp and go to edit his signature I want him to get notification on the header or change the header or something like that

the links are usually like this

http://www.xxxxx.com/forum/profile.php?do=buddylist
http://www.xxxxx.com/album.php?u=1
http://www.xxxxx.com/private.php?do=newpm
http://www.xxxxx.com/forumdisplay.php?f=10

so what I want is:
1- set a condition depending on the last part - which is in red- of the link.

2- set a condition depending on the whole link.

is there anyway to do that?
appreciate your help

best wishes :)

Dismounted
01-18-2009, 09:56 AM
I don't understand what you're trying to do there.

Super Jinni
01-18-2009, 10:17 AM
OK, let me say it in this way,

I have some customized header, so I want to change depending on the page that user going to visit, so some pictures will change in the main header, and some colors will change too.

so, I want to do that according to the url of the page that user visit. or according to the last part of the the url like what in red in the first post in this thread.

so, I want to do it in this way,

<if condition (the url is:www.whatever)> show this header</if>

or

<if condition (the last part of the url is: (/?do=buddylist or whatever)>show this or do this</if>

so I want to set a condition for whatever according to and depending on url or part of it.

I hope I could explain it clear enough. and sorry for my poor English.

so, is there any way to do something like that?

thanks again :)

Lynne
01-18-2009, 03:24 PM
If do=buddylist is in the url of the page you want to post your message on, have you tried just doing:
<if condition="$_REQUEST['do'] == 'buddylist'>
whatever
</if>

Super Jinni
01-18-2009, 03:47 PM
ok, I'll give that a try,
and what about the whole url?

I mean like in this thread's url

<if condition = the whole url is "https://vborg.vbsupport.ru/showthread.php?t=202215">
whatever
</if>

is that possible?

Lynne
01-18-2009, 03:56 PM
Not exactly. You can do a condition on (THIS_SCRIPT == 'showthread') or a condition on ($thread[threadid] == 202215) though.

Super Jinni
01-18-2009, 06:24 PM
Well, thanks Lynne. I used (THIS_SCRIPT) before and I think the ($_REQUEST ['do'] == whatever) will work for now.

really appreciate your help :)

thanks a lot

Dismounted
01-19-2009, 05:00 AM
You can actually find the request string (everything after the domain) using $_SERVER['REQUEST_URI'].

Super Jinni
01-19-2009, 11:27 AM
Thanks for your reply,
but I have a dumb question though :D:
how could I use that exactly? can you give an example please? :)

Dismounted
01-19-2009, 11:42 AM
<if condition="$_SERVER['REQUEST_URI'] == '/forum/member.php?u=1'">
This shouldn't really be used, ideally, you should use the THIS_SCRIPT constant along with other conditionals.

Super Jinni
01-19-2009, 11:03 PM
OK, thanks man,
really appreciate your your help, and Lynne of course. :)

may I ask you another question?

why shouldn't $_SERVER['REQUEST_URI'] be used? any security issues with it?

Dismounted
01-20-2009, 05:00 AM
why shouldn't $_SERVER['REQUEST_URI'] be used? any security issues with it?
Because it is not exact. It will not match every case of the URL that you expect. For example, you can access a forum (forumdisplay) with both f=X and forumid=X.

Super Jinni
01-20-2009, 04:04 PM
aaha,
OK, thank you so much for your help :)