Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Textplates installation problem (maybe php)
Sorry, this is txp related but not a txp problem, I think. Thame and I are stuggling with getting my template installed correctly on Textplates. All files, forms, pages etc on textplates and on my local install are the same. Thame was on 4.0.3 but has upgraded to txp 4.0.4. Everything works except the php style switcher. I’ve used the same code on several style switchers, have installed it fine several times and it works fine on different versions of txp so I don’t think it’s a txp problem. But I hope you can help cos it’s textplates :-)
Perhaps it is php incompatibility. Here’s the code I have, snipped for simplicity here and there:
On the web page:
<a href=”<txp:site_url />switch.php?css=b&style=s”>Bright I</a>
(This sends b and s to switch.php)
—————-
switch.php is like this:
<?php
$domain = “www.textplates.com/subdomain/0”;
if (stristr($_SERVER[‘HTTP_REFERER’], $domain)) {
$bounce_url = $_SERVER[‘HTTP_REFERER’];
} else {
$bounce_url = “http://$domain/”;
}
setcookie(‘s1’, $_GET[‘style’], time() + 31536000);
header(“Location: $bounce_url”);
?>
<?php
$domain = “www.textplates.com/subdomain/0”;
if (stristr($_SERVER[‘HTTP_REFERER’], $domain)) {
$bounce_url = $_SERVER[‘HTTP_REFERER’];
} else {
$bounce_url = “http://$domain/”;
}
setcookie(‘s2’, $_GET[‘css’], time() + 31536000);
header(“Location: $bounce_url”);
?>
(This collects b and s, puts them in cookies s2 and s1 and sends them to the head of the page
—————-
The head of the page has this:
<style type=“text/css” media=“screen,projection”> @import “<txp:site_url />textpattern/css.php?n=default”; </style><txp:php>
if ($_COOKIE[‘s2’]) { ?>
<link rel=“stylesheet” type=“text/css” media=“screen,projection” href=”<txp:site_url />textpattern/css.php?n=<?= $_COOKIE[‘s2’]; ?>” /> <?php } </txp:php>
<txp:php>
if ($_COOKIE[‘s1’]) { ?><link rel=“stylesheet” type=“text/css” media=“screen,projection” href=”<txp:site_url />textpattern/css.php?n=<?= $_COOKIE[‘s1’]; ?>” title=”<?= $_COOKIE[‘s1’]; ?>” /> <?php } </txp:php>
<txp:css format=“link” rel=“alternate stylesheet” media=“screen,projection” n=“s” title=“s” />
<txp:css format=“link” rel=“alternate stylesheet” media=“screen,projection” n=“b” title=“b” />
———————-
(The above should see the cookies but it doesn’t on this install.)
there’s this error message:
tag_error <txp:php> -> Notice: Undefined index: s2 on line 2
textpattern/publish/taghandlers.php(2681) : eval()’d code:2 unknown()
textpattern/publish/taghandlers.php:2681 eval()
textpattern/publish.php:958 php()
processtags()
textpattern/publish.php:917 preg_replace_callback()
textpattern/publish/taghandlers.php:277 parse()
textpattern/publish.php:958 output_form()
processtags()
textpattern/publish.php:917 preg_replace_callback()
textpattern/publish.php:453 parse()
——————-
So unlike all the other working versions of the switcher, this one does not receive the s2 cookie so it will not change the colour scheme.
Is any of my php, which is copied rather than understood, incompatible with older versions? Not that old however, here’s the diagnostics:
Textpattern version: 4.0.4 (r1956)
last_update: 2007-06-08 04:44:18/2007-06-08 04:44:18
Document root: /home/####/public_html
$path_to_site: /home/####/public_html/subdomain/0
Textpattern path: /home/####/public_html/browser/0/textpattern
Permanent link mode: section_title
Temp folder: /home/####/public_html/browser/0/textpattern/tmp
Site URL: www.textplates.com/subdomain/0
PHP version: 4.4.3
Register globals: 1
server_time: 2007-06-07 19:29:56
MySQL: 4.1.22-standard
Locale: en_GB.UTF-8
Server: Apache/1.3.37 (Unix) mod_auth_passthrough/1.8 mod_log_bytes/1.2 mod_bwlimited/1.4 FrontPage/5.0.2.2635.SR1.2 mod_ssl/2.8.28 OpenSSL/0.9.7a PHP-CGI/0.1b
php_sapi_mode: cgi
rfc2616_headers:
os_version: Linux 2.6.9-023stab040.1-entnosplit
active_plugins: glx_hl_current-0.3, zem_contact-0.6
.htaccess file contents:
————————————
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUEST_FILENAME} -d
RewriteRule ^(.+) – [PT,L]
RewriteRule ^(.*) index.php
————————————
(When using the .htaccess with <IfModule mod_rewrite.c> and with globals off, it crashes the site.)
Any ideas? Sorry about the long post.
Offline
#2 2007-06-08 16:06:14
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: Textplates installation problem (maybe php)
First, I would start with this:
<?php
if (!empty($_GET['style'])) {
setcookie('s1', $_GET['style'], time() + 31536000);
}
if (!empty($_GET['css'])) {
setcookie('s2', $_GET['css'], time() + 31536000);
}
$domain = 'textplates.com/subdomain';
if (!empty($_SERVER['HTTP_REFERER']) and stristr($_SERVER['HTTP_REFERER'], $domain)) {
$bounce_url = $_SERVER['HTTP_REFERER'];
} else {
$bounce_url = 'http://www.'.$domain.'/';
}
header("Location: $bounce_url");
?>
<style type="text/css" media="screen,projection">
@import "<txp:site_url />textpattern/css.php?n=default";
</style>
<txp:php>
$cookie_s1 = cs('s1');
$cookie_s2 = cs('s2');
if ($cookie_s2) {
echo n.'<link rel="stylesheet" type="text/css" media="screen,projection" href="'.hu.'textpattern/css.php?n='.$cookie_s2.'" />';
}
if ($cookie_s1) {
echo n.'<link rel="stylesheet" type="text/css" media="screen,projection" href="'.hu.'textpattern/css.php?n='.$cookie_s1.'" title="'.$cookie_s1.'" />';
}
</txp:php>
<txp:css format="link" rel="alternate stylesheet" media="screen,projection" n="s" title="s" />
<txp:css format="link" rel="alternate stylesheet" media="screen,projection" n="b" title="b" />
(Edit: code updated.)
Last edited by Mary (2007-06-08 22:19:54)
Offline
Re: Textplates installation problem (maybe php)
Mary, you are an angel! It’s all working now. If I was thirty years younger I’d be asking you to marry me! (Phew, that was a lucky escape for you :-) I would also learn some php properly! I’m afraid things just don’t travel through the brain cells like they used to.
Just for purity’s sake, is there a better way to write this:
href="http://'.$prefs['siteurl'].'/textpattern/css.php?
You had put:
href="'.$prefs['sitename'].'textpattern/css.php?
I had a lucky guess with siteurl but wonder if there is a purer way to do it.
Thanks again! You’re a genius too.
Offline
#4 2007-06-08 22:26:36
- Mary
- Sock Enthusiast
- Registered: 2004-06-27
- Posts: 6,236
Re: Textplates installation problem (maybe php)
Whoops and a ‘duh’ on my part. See the updated code.
As to marriage proposals… you would’ve had to stand in line any way, but only because I’ve helped lots of guys in a jam before you. ;D
Offline
Re: Textplates installation problem (maybe php)
Wow, that’s trimmed the code right down. No wonder there’s a long line of guys who only want you for your coding! But I love you for your heart of gold too. And whatever you may look like you are gorgeous! May you continue to knock ‘em dead for many years to come!
Offline