1 stevet May 06, 2005 22:07
3 stevet May 06, 2005 23:14
thanks for that scott. I think my preferred route will be alternate CSS. It's an excellent choice to present a highly stylised skin into something more accessable. I can create the style sheets easy but I'll have to read the explanation again to understand how to do the switching. I have 53 year old eyesight and the script examples on alistapart were not very .....erm .... accessable
4 stk May 06, 2005 23:35
stevet,
I had a quick read on the list a part articles (after finding them and linking them here).
The so called "modern browsers" generally allow style switching from within the browser window, but the drawback is that it's not persistent.
So ... a bit of javaScript trickery is employed (but apparently, if you're so inclined, you can use PHP instead) to do the choosing for you and then writes a cookie crumb that makes the choice persistent.
I would imagine that there a *lots* of such PHP/Java scripts out there that allow skin-switching. What I'm driving at here is that maybe the fastest solution would be to pass on the *ironically inaccessible* List-A-Part articles (which are kinda like the web's version of a do-it-yourself 'build a radio at home') and oogle the Internet for pre-existing script solutions.
Just a thought.
-Scott
5 stk May 06, 2005 23:50
In an attempt to put money where my mouth is, I found this PHP Styleswitcher code on the Internet. :D
(Completely untested, of course ... but it does have several features which put it into the "I bet this will probably do what I want" column:
1) Has an example page.
2) Comes in two flavors (simple and newer, more robust)
3) Has Documentation
4) Has links to the author (and his pages are nice, accessible & use berry good English)
5) Uses PHP instead of Java (server-side solutions are better)
6) Pages validate (attention to detail)
Anyway ... I bet it will work for you too! ;)
Here's the link: [url=http://www.contrastsweb.com/switcher/v2/]PHP Styleswitcher v2[/url] (the robust one)
EDIT: I had a look and this is more involved than what you might need or want. I found a much more simple thing [url=http://archivist.incutio.com/viewlist/css-discuss/8414]HERE[/url] For what you're doing, I think it *might* be more appropriate. (no tutorial or webpage or anything, but seems farily straight forward)
6 stevet May 07, 2005 10:31
nearly got it but it's just eluding me - a new mind and pair of eyes on it may see the answer. I thinks its something about the way URL's are being called
I've implimented it on a spare B2 EVO install here
http://neukol.org.uk/b2/animatus/index.php/skinswitch
it works (with a few errors) if I can call up:
http://neukol.org.uk/b2/animatus/index.php/skinswitch?newstyle=large
but it calls up
http://neukol.org.uk/skinswitch?newstyle=large
I think the fault may be here:
<span class="large">[<a title="View in Accessable fonts and colours" href="<? print
$PHP_SELF."?newstyle=large"?>">View in Accessable fonts and colours</a>]</span>
<span class="default">[<a title="View in Normal Colours"
href="<? print $PHP_SELF."?newstyle=default"?>">View in Normal Colours</a>]</span>
I've called up the CSS using this
<link rel="stylesheet" href="<? print $csstyle?>.css"; type="text/css" />
which is my interpretation of what the guy was saying
my files are here
http://www.neukol.org.uk//b2/animatus/skins/nu_ship
_main.php
styleswitch.php
default.css
large.css
7 yabba May 07, 2005 10:57
Try :-
<span class="large">[<a title="View in Accessable fonts and colours" href="<? echo $baseurl ?>"/index.php/skinswitch?newstyle=large">View in Accessable fonts and colours</a>]</span>
<span class="default">[<a title="View in Normal Colours"
href="<? <? echo $baseurl ?>"/index.php/skinswitch?newstyle=default">View in Normal Colours</a>]</span>
¥
8 stevet May 07, 2005 11:07
thanks - I'll try that but it looks to me like that will that would make it blog dependent ie if soemone else used the same skin they would invoke a different blog to their own if the tried to switch skins
9 yabba May 07, 2005 11:17
You're probably right, unfortunately I use a windows server so I can't use the url system that you do, so I can't check your code.
However, your problem at the moment is that $PHP_SELF generates :-
http://neukol.org.uk/skinswitchb2/animatus/index.php/
instead of :-
http://neukol.org.uk/b2/animatus/index.php/skinswitch
I suppose you could change it to :-
$myUrl =str_replace('skinswitch','',$PHP_SELF).'skinswitch/";
and then use $myUrl where you have $PHP_SELF at the moment
¥
10 stevet May 07, 2005 11:47
$PHP_SELF was at first generating
http://neukol.org.uk/skinswitch
which is almost right but part of the path is missing
after hacking around I caused it to generate
http://neukol.org.uk/skinswitchb2/animatus/index.php/
It's entirely wrong but at least I effected some change
however I can not get it to go back to the original so whatever I have hacked I seem to be unable to alter it
here's the skinswitch.php
<?php
//process any new request
if ($newstyle){
$csstyle=$newstyle;
setcookie("csstyle", $csstyle, time()+360000, "/", "neukol.org.uk/", 0);
}
//set to default if not specified
if ( !isset ($csstyle)){
$csstyle="default";
}
?>
that line with neukol.org.uk in it is the culprit I think. I altered that from the original to rflect my own URL and it is this that I altered which causes that wrong URL to persist even though I have changed it back. I don't understand what any of this code is doing which is what makes it hard fort me to know what to change
11 yabba May 07, 2005 11:52
I wouldn't have thought that setting a cookie would have changed $PHP_SELF, but I'm not exactly a php programmer.
The code I posted above should rearrange the url to what you need it to be.
¥
12 stevet May 08, 2005 09:01
¥åßßå wrote:
Try :-
<span class="large">[<a title="View in Accessable fonts and colours" href="<? echo $baseurl ?>"/index.php/skinswitch?newstyle=large">View in Accessable fonts and colours</a>]</span> <span class="default">[<a title="View in Normal Colours" href="<? <? echo $baseurl ?>"/index.php/skinswitch?newstyle=default">View in Normal Colours</a>]</span>
¥
¥åßßå,
I've tried that but I'd adapted the code a little
<span class="large">[<a title="View in Accessable fonts and colours" href=" <? echo $baseurl ?>/index.php/skinswitch?newstyle=large">View in Accessable fonts and colours</a>]</span>
<span class="default">[<a title="View in Normal Colours" href="<? echo $baseurl ?>/index.php/skinswitch?newstyle=default">View in Normal Colours</a>]</span>
yours had a double (typo) <? <? around line 3
in this line
href="<? echo $baseurl ?>"/index.php/skinswitch?newstyle=large">
i took out the " after the baseurl to read thus:
<span class="default">[<a title="View in Normal Colours" href="<? echo $baseurl ?>/index.php/skinswitch?newstyle=default">View in Normal Colours</a>]</span>
So now it works (kind of) http://neukol.org.uk/b2/animatus/index.php/skinswitch
it returns the correct URL but adds some errors I don't understand.
if I can fix that bit then I have a solution that will work for this blog project. However if someone else wanted to use the same skin (and they WILL) clicking on accessability will swith to another skin but also switch to another blog.
so what I want to do is - 1) get this to work then 2) find a solution that is independent and will work in any skin/blog
13 stevet May 08, 2005 09:23
I've tried again here
http://neukol.org.uk/b2/animatus/index.php/Skinswitch2
I used this in styleswitch.php
<?php
//process any new request
if ($newstyle){
$csstyle=$newstyle;
setcookie("csstyle", $csstyle, time()+360000, "/", "<? echo $baseurl ?>", 0);
}
//set to default if not specified
if ( !isset ($csstyle)){
$csstyle="default";
}
?>
and in _main.php I added this
<span class="large">[<a title="View in Accessable fonts and colours" href="<? print
$PHP_SELF."b2/animatus/index.php/?newstyle=large"?>">View in Accessable fonts and colours</a>]</span>
<span class="default">[<a title="View in Normal Colours"
href="<? print $PHP_SELF."?newstyle=default"?>">View in Normal Colours</a>]</span>
OK - so it doesn't work but HOW it doesn't work is interesting
it delivers this URL
http://neukol.org.uk/Skinswitch2b2/animatus/index.php/?newstyle=large
which is almost right
http://neukol.org.uk/b2/animatus/index.php/Skinswitch2?newstyle=large
I can't figure what I'm doing wrong but surely this must be getting close
The "correct" URL still returns some errors
14 yabba May 08, 2005 09:37
Lets see if we can narrow things down.
Replace :-
<span class="large">[<a title="View in Accessable fonts and colours" href="<? print
$PHP_SELF."b2/animatus/index.php/?newstyle=large"?>">View in Accessable fonts and colours</a>]</span>
<span class="default">[<a title="View in Normal Colours"
href="<? print $PHP_SELF."?newstyle=default"?>">View in Normal Colours</a>]</span>
With
<span class="large">[<a title="View in Accessable fonts and colours" href="<? print
$PHP_SELF."b2/animatus/index.php/?newstyle=large"?>">View in Accessable fonts and colours</a>]</span>
<span class="default">[<a title="View in Normal Colours"
href="<? print $PHP_SELF."?newstyle=default"?>">View in Normal Colours</a>]</span>
<?
$myUrl=str_replace('skinswitch','',$PHP_SELF);
echo "Php self = ".$PHP_SELF."/n";
echo "My Url = ".$myUrl;
?>
And see what the 2 echo statements output
15 stevet May 08, 2005 09:44
16 yabba May 08, 2005 09:53
ok, now try :-
<a href="<? $skinbase();
echo '../../index.php/'.$PHP_SELF ?>?newstyle=default">Default</a>
<a href="<? $skinbase();
echo '../../index.php/'.$PHP_SELF ?>?newstyle=large">Large</a>
And see if that's any closer
¥
17 stevet May 08, 2005 10:33
done
<span class="large">
<a href="<? $skinbase(); echo '../../index.php/'.$PHP_SELF ?>?newstyle=large">Large</a>
</span>
<span class="default">
<a href="<? $skinbase(); echo '../../index.php/'.$PHP_SELF ?>?newstyle=default">Default</a>
</span>
http://neukol.org.uk/b2/animatus/index.php/Skinswitch2
"fatal error call to undefined function"
18 yabba May 08, 2005 10:33
Sorry mate, that should be <? skinbase(); (without the $).
¥
19 yabba May 08, 2005 10:37
Ok, just seen, you're almost there.
Chage both ......index.php/ to ..........index.php and it should all work ;)
¥
20 stevet May 08, 2005 10:39
nearly there maybe
I used this
<span class="large">
<a href="<? skinbase(); echo '../../index.php'.$PHP_SELF ?>?newstyle=large">Large</a>
</span>
<span class="default">
<a href="<? skinbase(); echo '../../index.php'.$PHP_SELF ?>?newstyle=default">Default</a>
</span>
NB - I took out the trailing /'s after index.php as itappeared twice in the resulting URL
it kinda works - ar least it delivers rthe right URL and shows the blog in teh accessable skin. However it produces errors so I guess that's the next thing to crack
I gotta go out now though
thanks for your help
21 stevet May 08, 2005 14:58
I can stop the errors appearing by taking out the cookies line in the styleswitch.php
<?php
//process any new request
if ($newstyle){
$csstyle=$newstyle;
setcookie("csstyle", $csstyle, time()+360000, "/", "neukol.org.uk", 0);
}
//set to default if not specified
if ( !isset ($csstyle)){
$csstyle="default";
}
?>
however clicking anything on the page reverts to the old style and not the acessable one if chosen by the user. This happens even without the cookies lien to so it's my understanding that I must have to get cookies working right for the chosen style to be pervasive throught the blog
22 yabba May 08, 2005 15:21
Found this on the php.net site
Cookies are part of the HTTP header, so setcookie() must be called before any output is sent to the browser.
It might help you narrow down a solution
¥
23 stk May 08, 2005 15:30
Stevet,
I'm jumping in a little late here, but I had a boo at your site and see that you're getting a "headers" error.
I've seen this before.
From the original doc on the styleswitcher code, it explains a bit about this and how to fix it. Yabba is right ... it's got to be the VERY first thing (like no blank lines, no spaces, no nothin). Shove that little <?php right into the upper left-hand corner of the file!
Errors you may get
If you get an error saying that your headers have already been sent out, this means that you have outputed text or whitespace before you called setcookie() or header(). This causes problems because both send out HTTP headers, but because there is text before this, the headers have already been sent to the client.
Ok, how do you fix this? Make sure there is no whitespace or text before you call either of these functions. The only place in our example where these functions are used is in the "switcher.php" file, so be sure to check for whitespace before the opening <?php.
Also, parse errors are generally caused by forgotten ";" or misplaced quotes or curly braces. When you get an error like this look at the line number in your script and a few around it. Sometimes it isn't exactly where PHP says the error is.
-Scott
24 stevet May 08, 2005 16:42
whahey that fixed it
http://neukol.org.uk/b2/animatus/index.php/Skinswitch2
thanks guys
I shall now deploy it to the actual site
perhaps I should now post a summary of how this works cos it's somewhat different to the solution the original guy posted
25 stevet May 08, 2005 16:55
26 stk May 08, 2005 17:08
Looks Great! :D
My only suggestion would be to change the "The Tall Ships RAce" font to a PX or PT (rather than % or em) ... to keep the header looking the same in both. (The header text is big enough already).
If you did a write-up, it would be useful. I could see using this capability some day and it would be great to have a b2evo-specific instruction set.
Glad it worked out. B)
-Scott
27 stevet May 08, 2005 17:32
With special thanks to Geoff Sheridan who created this solution http://archivist.incutio.com/viewlist/css-discuss/8414 and to ¥åßßå and Scott (STK) I finally have a solution to a problem. How to show a blog in two skins that would persist through the blog when various links are clicked. One skin for artistic merit and the other for more acessability.
Here is the site http://neukol.org.uk/tyneblog/index.php/tallships
and here is the solution
- The skin I was using called up the custom.css so I made two copies of it and called one default.css and the other large.css (you could use your own names but I found this easier than changing the calls in various parts of the script) I left default.css exactly as it was and tweaked large.css to make it more readable for people with sight difficulties. This included larger fonts and changing the colour scheme[/list:u]
- in default.css I added the line .default{display:none;}[/list:u]
- in large.css I added the line .large{display:none;}[/list:u]
next I added the following to _main.php
<?php include("styleswitch.php"); ?>
this is at the very top of the document with no white space no nothing preceding it. At first I took Geoffs instruction literally and placed it this was not good enough and caused some errors as it was before the HTML tag but not at the top of the document. next in _main.php I found the line:-before the HTML tag
<link rel="stylesheet" href="custom.css" type="text/css" />
and deleted it and in its place put this:
<link rel="stylesheet" href="<? print $csstyle?>.css"; type="text/css" />
NB this differs quite a bit from what Geoff suggests in his instructions.
Now a new PHP file has to be created and added to the skins other files
this is called styleswitch.php and goes something like this:
<?php
//process any new request
if ($newstyle){
$csstyle=$newstyle;
setcookie("csstyle", $csstyle, time()+360000, "/", "neukol.org.uk", 0);
}
//set to default if not specified
if ( !isset ($csstyle)){
$csstyle="default";
}
?>
I confess I don't know what this file is doing but I changed geoff's base URL to my own (neukol.org.uk) and it seems to do the trick.
Finally ¥åßßå to the rescue and the following code was placed in _main.php where I wanted the switch link to appear
<span class="large">
<a href="<? skinbase(); echo '../../index.php'.$PHP_SELF ?>?newstyle=large">View in Accessible fonts and colours</a>
</span>
<span class="default">
<a href="<? skinbase(); echo '../../index.php'.$PHP_SELF ?>?newstyle=default">View in original style</a>
</span>
I have not tested the theory yet but it seems to me that the same skin could be used by another blog and work perfectly well with a whole other set of content.
Hope this helps others who might want to do the same. It will also serve to help me remember waht the F to do when I want to deploy this again. I'm sure to want to use it lots but I think it could also have some quite creative/artistic uses28 staypuft Sep 21, 2005 19:18
Any ideas of how to make the styleswitcher work with stubs?
<a href="<? skinbase(); echo '../../index.php'.$PHP_SELF ?>?newstyle=default">View in original style</a>
That code only works if all blogs are being displayed through index.php.
I've tried using bloginfo('blogurl') instead of skinbase() but that only works in conjunction with $PHP_SELF when it's not on the main page of the blog (just the stub and nothing after it).
I tried using if statements to check to see it you're at the main stub or at a specific post, and then select which link to use accordingly, but i couldn't get it to work.
The problem seemed to be $PHP_SELF so i ditched it and I'm currently using:
<a href="<?php bloginfo('blogurl') ?>?newstyle=default">View in original style</a>
but this takes you back to the main page (stub) of the blog instead of returning you to the post you were viewing before you changed that style.
Any ideas of how to make the styleswitcher work whether you're at the main page stub of a blog or at specific post through a stub?
29 yabba Sep 22, 2005 11:25
Try :-
<a href="<?php echo $baseurl.'/'.regenerate_url('','newstyle=default') ?>">View in original style</a>
¥
30 staypuft Sep 22, 2005 17:43
¥åßßå wrote:
Try :-
<a href="<?php echo $baseurl.'/'.regenerate_url('','newstyle=default') ?>">View in original style</a>
Ah, bingo! I knew there was a function like "regenerate_url()", but I couldn't find it.
"<?php echo $baseurl.'/'.regenerate_url('','newstyle=default') ?>" generates an extra "/blog" (the blog root dir) in the URL so i tweaked it a teeny tiny to:
<a href="<?php echo $baseurl.'/..'.regenerate_url('','newstyle=default') ?>">View in original style</a>
This generates URLs to switch the style on any page, whether you're at a specific post, a specific page within search results or the main page of a stub... everywhere.
Thanx ¥åßßå, stevet, and [url=http://archivist.incutio.com/viewlist/css-discuss/8414]Geoff Sheridan[/url]. I very much prefer this method of skin switch as it doesn't reply on javascript like other styleswitchers I've tried.
31 staypuft Sep 22, 2005 19:29
stevet wrote:
next in _main.php I found the line:-
<link rel="stylesheet" href="custom.css" type="text/css" />
and deleted it and in its place put this:
<link rel="stylesheet" href="<? print $csstyle?>.css"; type="text/css" />
In the interest of xhtml valid code, I removed the extraneous semicolon from
<link rel="stylesheet" href="<? print $csstyle?>.css"; type="text/css" />
32 yabba Sep 22, 2005 19:35
"<?php echo $baseurl.'/'.regenerate_url('','newstyle=default') ?>" generates an extra "/blog" (the blog root dir) in the URL so i tweaked it a teeny tiny to:
Lol, knew I should have created a stub to test it :p
¥
33 stevet Jan 20, 2006 17:51
After all this time - this no longer works for me. Only difference is moving to a new server. Invoking the "new accessable skin" link causes it to show this URL
http://neukol.org.uk/tyneblog/index.php/tyneblog/index.php/tallships?newstyle=large
where
tyneblog/index.php
is in twice causeing a 404. I'm going through this now to try to figure it but some eagle eye may see te answer right off. I'm a bit stumped right now.
34 yabba Jan 21, 2006 10:59
try :-
echo regenerate_url('', 'newstyle=large');
and see what gets displayed.
¥
35 stevet Jan 27, 2006 14:23
<span class="large">
<a href="<? skinbase(); echo regenerate_url('', 'newstyle=large');">View in Accessible fonts and colours</a>
</span>
displays
Parse error: parse error, unexpected T_DEFAULT in /homepages/13/d137553926/htdocs/public_html/tyneblog/skins/nu_ship/_main.php on line 169
tried taking out the ; between large') and ">
and got this
Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ',' or ';' in /homepages/13/d137553926/htdocs/public_html/tyneblog/skins/nu_ship/_main.php on line 169
36 yabba Jan 27, 2006 18:11
Sorry, I wasn't quite clear, what I meant was, just put echo regenerate_url('','newstyle=large'); on a line of it's own (in approx the same location, and seeing what b2evo spits out for it. (don't forget it needs to be between <?php & ?> )
¥
37 stevet Jan 28, 2006 10:11
OK following more carefully what you said the following is generated where I put your line of code
/tyneblog/index.php/tallships?
this is at http://neukol.org.uk/tyneblog/index.php/tallships
38 yabba Jan 28, 2006 11:07
<span class="large">
<a href="<?php echo regenerate_url('', 'newstyle=large'); ?>">View in Accessible fonts and colours</a>
</span>
;)
¥
39 stevet Jan 28, 2006 11:18
http://neukol.org.uk/tyneblog/index.php/tallships
It works !!!! :D
Thank you so much for your generosity
40 yabba Jan 28, 2006 11:19
No problem ;)
¥
41 stevet Feb 09, 2006 16:42
Oh Shit >:-<
it stopped working again
<span class="large">
<a href="<?php echo regenerate_url('', 'newstyle=large'); ?>">View in Accessible fonts and colours</a>
</span>
<span class="default">
<a href="<?php echo regenerate_url('', 'newstyle=default'); ?>">View in original style</a>
</span>
brings up this
Parse error: parse error, unexpected T_CONSTANT_ENCAPSED_STRING, expecting ',' or ';' in /homepages/13/d137553926/htdocs/public_html/tyneblog/skins/nu_ship/_main.php on line 169
42 stevet Feb 09, 2006 16:55
I fixed it AGAIN ! :oops:
Stevet,
Rather than a skin, why not just use a CSS style switcher? Basically, it's just a link on the existing blue skin that will swap out the 'preferred' CSS file for an 'alternate' one. Keep the skin, just change the font to black and the background to a lighter shade of pale (blue, that is).
I know that "A List Apart" has a couple of articles about this technique:
[url=http://www.alistapart.com/articles/alternate/]Working w/Alternate Style Sheets[/url]
[url=http://www.alistapart.com/articles/phpswitch/]Build a PHP Switcher[/url]
[url=http://www.alistapart.com/articles/n4switch/]A Backwards Compatible Style Switcher[/url][/list:u]Hope these help. (You could always oogle the 'net for more tutorials using keywords: "CSS" "STYLE" "SWITCHING")