design.ersblock - The Web's Friendliest Forum
September 10, 2010, 10:52:00 PM *
Welcome, Guest. Please login or register.
Did you miss your activation email?
Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Anyone use Text Pattern  (Read 1442 times)
0 Members and 1 Guest are viewing this topic.
Devil7
Founder
Member
*****
Posts: 1958


devil7@tech22.co.uk
View Profile WWW
« on: August 01, 2008, 10:16:56 AM »

I#m very stuck on a plugin for text pattern that is basicly a "if/else" condition, but it's not that straight forward, wondered if anyone of you guys knows anything!!

also, if this doesn't work, could someone point me in the right direction for doing an " if url is x do this, else do that" in PHP

thanx guys
Logged

Don't wish life was easier,
wish you were better

- Jim Rohn
wattsa
Member
**
Posts: 124


View Profile WWW
« Reply #1 on: August 01, 2008, 10:59:04 AM »

Here is some php code I use to detect whether I am using my local webserver or the actual website.

Code:
switch ($_SERVER['SERVER_NAME']) {
case "localhost":

break;
case "www.blah.com":
case "blah.com":

break;
}
just put your php code before the break statements
Logged
Devil7
Founder
Member
*****
Posts: 1958


devil7@tech22.co.uk
View Profile WWW
« Reply #2 on: August 01, 2008, 01:49:42 PM »

thanks wattsa
i'll try that

what about if you wanted to see it on www.qwerty.com/this.php but not on www.qwerty.com/then.php ??
Logged

Don't wish life was easier,
wish you were better

- Jim Rohn
wattsa
Member
**
Posts: 124


View Profile WWW
« Reply #3 on: August 01, 2008, 02:49:00 PM »

Try replacing SERVER_NAME with REQUEST_URI or PHP_SELF

This should check the last part of your URL  ie this.php or then.php

Try echoing all 3 $SERVER VARIABLES to work out which you need or a combination of 2 of them.


Logged
Devil7
Founder
Member
*****
Posts: 1958


devil7@tech22.co.uk
View Profile WWW
« Reply #4 on: August 01, 2008, 03:02:06 PM »

Cheers Wattsa

so where do i put the html i need to display (or not display)?
Logged

Don't wish life was easier,
wish you were better

- Jim Rohn
wattsa
Member
**
Posts: 124


View Profile WWW
« Reply #5 on: August 01, 2008, 04:19:01 PM »

Code:
<?php
switch ($_SERVER['SERVER_NAME']) {
case "localhost":
                          
$main "<p>This is the stuff I want to do for this page.</p>";
break;
case "www.blah.com":
case "blah.com":
                          
$main "<p>This is the stuff I want to do for the other page.</p>";
break;
}
?>

<body>
     <?php echo $main?>
</body>
Logged
Devil7
Founder
Member
*****
Posts: 1958


devil7@tech22.co.uk
View Profile WWW
« Reply #6 on: August 01, 2008, 08:44:53 PM »

OK, looks like i've got that sorted.. thanks Wattsa...

now i need to do this...

if REQUEST_URI == 'this-page' OR 'that-page'
do this

ive got the if statment to work fine with 1
IE:
if REQUEST_URI == 'this-page'

but i need to specify more than one uri or the whole thing will get very messy...
any help as usual will be appriciated
Logged

Don't wish life was easier,
wish you were better

- Jim Rohn
wattsa
Member
**
Posts: 124


View Profile WWW
« Reply #7 on: August 02, 2008, 05:38:47 AM »

The OR in php is ||

so:

Code:
if ($_SERVER('REQUEST_URI') == 'this-page' ||  $_SERVER('REQUEST_URI') == 'that-page') {
}
Logged
Devil7
Founder
Member
*****
Posts: 1958


devil7@tech22.co.uk
View Profile WWW
« Reply #8 on: August 02, 2008, 08:32:48 AM »

cheers bud...
i was doing

if ($_SERVER('REQUEST_URI') == 'this-page' ||  == 'that-page')

always little things
Logged

Don't wish life was easier,
wish you were better

- Jim Rohn
Devil7
Founder
Member
*****
Posts: 1958


devil7@tech22.co.uk
View Profile WWW
« Reply #9 on: December 22, 2009, 01:17:10 PM »

Switched to Wordpress a while ago, better all round - textpattern is ok but a bit clunky, and WP has a better community
Logged

Don't wish life was easier,
wish you were better

- Jim Rohn
Pages: [1]
  Print  
 
Jump to:  

English Steel 1.6 © Saxon North Technologies
Powered by MySQL Powered by PHP Powered by SMF 1.1.9 | SMF © 2006-2009, Simple Machines LLC Valid XHTML 1.0! Valid CSS!