Recent Topics

1 May 06, 2005 22:07    

I've set up this blog for an educational group

http://neukol.org.uk/tyneblog/index.php/tallships

I don't want skin switching as the design reflects the event to be blogged. There are potential probs with some users of white text on blue so I can set up a link to show the same blog in a plain skin

http://neukol.org.uk/tyneblog/index.php/tallships?skin=nu_simple

the problem is I know that when more posts are added when the "next page" link is added the skin will revert to the set style.

Anyone know how I can either force teh plain sking to stay put of how any other way I can make the blog viewable in it's intended skin plus one plain skin.

Perhaps setting up a second blog with a plain skin that does not display any posts but sucks all these ones in ??

2 May 06, 2005 22:43

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:

3 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 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 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 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 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 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 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 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 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 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 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 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

16 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 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 May 08, 2005 10:33

Sorry mate, that should be <? skinbase(); (without the $).

¥

19 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 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 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 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 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

26 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 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

        before the HTML tag

        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:-
        <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 uses

28 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 Sep 22, 2005 11:25

Try :-
<a href="<?php echo $baseurl.'/'.regenerate_url('','newstyle=default') ?>">View in original style</a>

¥

30 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 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 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

¥

34 Jan 21, 2006 10:59

try :-

echo regenerate_url('', 'newstyle=large');

and see what gets displayed.

¥

35 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 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 & ?> )

¥

38 Jan 28, 2006 11:07

<span class="large">
<a href="<?php echo regenerate_url('', 'newstyle=large'); ?>">View in Accessible fonts and colours</a>
</span>

;)

¥

41 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 Feb 09, 2006 16:55

I fixed it AGAIN ! :oops:


Form is loading...