1
studioC
playing with a styleswitcher
  • 2005/2/25 20:04

  • studioC

  • Friend of XOOPS

  • Posts: 922

  • Since: 2003/12/7


i'm actually playing a bit with a styleswitcher on http://studiocreativ.de

with a script found on ala and mentioned:
HERE

opinions or other, easier solutions to switch a style? can we use smarty to assign different pathes to sheets and set a session or handle this?

michael

2
simeon
Re: playing with a styleswitcher
  • 2005/2/25 22:29

  • simeon

  • Not too shy to talk

  • Posts: 104

  • Since: 2003/12/18


wenn noch bis morgen wartest bekommst nen funktionierenden switcher mit cookie ;)

3
simeon
Re: playing with a styleswitcher
  • 2005/2/28 9:39

  • simeon

  • Not too shy to talk

  • Posts: 104

  • Since: 2003/12/18


now, here it is.i hope it works for everybody

maybe someone could be so kind as to post suggestions about the code.im no coder therefore i cant say anything ´bout quality or security things.im glad that it works (for me)

thanks in advanced

//1. /themes/yourtheme/switch.php <?php $set = $_GET['set']; $set = preg_replace('#[^a-zA-Z0-9_-]#', '', $set); setcookie ('style', $set, time()+31536000, '/', 'yoursite.com', '0'); header("Location: $HTTP_REFERER"); ?>  //2. /themes/yourtheme/theme.html -> before line 1 <{php}> include_once XOOPS_URL.'/themes/yourtheme/switch.php'; if ( isset($_COOKIE['style'])) { $sstyle = $_COOKIE['style']; $GLOBALS['xoopsTpl']->assign( 'xoops_sstyle', $sstyle); } else { $sdefault = 'style'; $GLOBALS['xoopsTpl']->assign( 'xoops_sstyle', $sdefault); } <{/php}> //3. /themes/yourtheme/theme.html -> relpace the default theme css link with <link rel="stylesheet" type="text/css" media="screen" href="<{$xoops_imageurl}><{$xoops_sstyle}>.css" /> //4. wherever :) -> switch-link , replace "style" with the css name you want to switch examples <a href="<{$xoops_imageurl}>switch.php?set=style1">Style1</a> <a href="<{$xoops_imageurl}>switch.php?set=style2">Style2</a>

4
studioC
Re: playing with a styleswitcher
  • 2005/2/28 17:41

  • studioC

  • Friend of XOOPS

  • Posts: 922

  • Since: 2003/12/7


hello simeon,

i tryed your solution, but clicking on a link (either style 1 or 2) gives only blank page.

of course i have changed "yoursite.com" and "include_once XOOPS_URL.'/themes/yourtheme/includes.php';" to
"include_once XOOPS_URL.'/themes/yourtheme/switch.php';" (though tested both versions) for there is no includes.php in themefolder ...

what am i doing wrong?
michael

5
simeon
Re: playing with a styleswitcher
  • 2005/2/28 18:28

  • simeon

  • Not too shy to talk

  • Posts: 104

  • Since: 2003/12/18


lol sure includes.php is was my fail.you need to include switch.php

what happens if you call the switch.php directly?does it write the cookie?

i got problems with that too but think i got it cause it runs on all my sites.normally theres nothing to do wrong with that cookie thing.

Login

Donat-O-Meter

Stats
Goal: $15.00
Due Date: Jul 31
Gross Amount: $0.00
Net Balance: $0.00
Left to go: $15.00
Make donations with PayPal!

Latest GitHub Commits