Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
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
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
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
Pages: 1