Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2007-10-01 02:19:11

Jeremie
Member
From: Provence, France
Registered: 2004-08-11
Posts: 1,578
Website

Extracting the URL?

I need to extract the URL (the full one, or the TXP specific part, doesn’t matter) of the current webpage displayed by TXP inside a <txp:php>...</txp:php> tag to use it as a condition.

Does anyone knowledgeable in the TXP code mechanic knows how to do this?

For example, if I’m in www.mysite.com/mysection/anArticle, I need to do something like this:

if URL ends with "anArticle"
...
else
...

And I can’t work around it inside the usual TXP plugins or tags.

Last edited by Jeremie (2007-10-01 02:19:45)

Offline

#2 2007-10-01 03:55:04

iblastoff
Plugin Author
From: Toronto
Registered: 2006-06-11
Posts: 1,197
Website

Re: Extracting the URL?

i’m assuming some simple $_SERVER[‘REQUEST_URI’] might help here?

havent tried this plugin but it might be of some help as well.

Offline

#3 2007-10-01 06:16:49

marios
Archived Plugin Author
Registered: 2005-03-12
Posts: 1,253

Re: Extracting the URL?

For individual article page, try something like this:

 // exec statement depending on permlink req uri
       <txp:php>
    global $thisarticle;
		if (!empty($thisarticle['url_title'])) {
			$rq = $thisarticle['url_title'];
			//echo $rq;
			$cond = 'test-condition-string';
			if ($rq == $cond) {
				# do something
			}
			else {
				# do something else
			}

} </txp:php>

regards, marios

Last edited by marios (2007-10-01 15:12:11)


⌃ ⇧ < ⌃ ⇧ >

Offline

#4 2007-10-02 08:51:49

Jeremie
Member
From: Provence, France
Registered: 2004-08-11
Posts: 1,578
Website

Re: Extracting the URL?

chs_if_urlvar is nice, but hasn’t been updated in a while.

However, Mario’s code should work fine.

Thanks to both.

Offline

Board footer

Powered by FluxBB