FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


Need help skinning





scimitarmoon
Let me begin by saying I feel like a moron. I've done this once before and got it to work with no problems whatsoever. That said, I am trying to make some different site skins for my sister's frihost website (which will explain why the stuff in the code doesn't match up with my info, I hope).

I followed the guide on this site: http://www.domesticat.net/skins/howto.php. It worked for me before, when I was simply using layouts with a different header picture but overall the same structure. That was on a different host before we/she moved the site to frihost. Now I am trying to do slightly more complex layouts using divs instead of tables so that the layouts can be more diverse. There's less formatting code on the pages now, so I figured it would be easier to do the whole skin thing.

So I went in and altered the code that I had used successfully to reflect the new formats. I thought that formatting was all I changed, but I can't seem to get the new skin to "stick" past the test/selection page. What I mean is that the new skin shows up no problem after clicking "make this my skin", but once you click back to the index page the old skin shows up again. I think this means I'm setting the cookie wrong, but I'm a total php newbie and it really could be anything. I've been over and over the code for the last week and can't find what I'm doing wrong, so I'm hoping someone here can enlighten me (and that it's not some really idiotic, simple mistake that'll make me facepalm at my own stupidity).

The problem site is found (in all its stunted, not functioning glory) here: http://www.chocolate-roses.org/test/index.php

This is the code that I have to set the cookie for the skin (it's pretty much identical to that found in the tutorial, with this site's parameters plugged in):

Code:
<?

$total_skins = 2;
$default_skin = 1;

  if (isset($_REQUEST['newskin'])) {
    $newskin=(int)$_REQUEST['newskin'];
    if ( ($newskin<1) OR ($newskin>$total_skins) ) $newskin=$default_skin;
  } elseif (isset($_REQUEST['skin'])) {
    $newskin=(int)$skin;
    if ( ($skin<1) OR ($skin>$total_skins) ) $newskin=$default_skin;
  } else $newskin=$default_skin;

  $skin=$newskin;
  setcookie ('skin', "", time() - 3600);
  setcookie('skin',$newskin,time()+(86400*365),'/');
  setcookie('skin',$newskin,time()+(86400*365),'/','.chocolate-roses.org');
  $skin=$newskin;


    $headervar = "/home/chalchih/domains/chocolate-roses.frih.net/public_html/test/nav/header";
    $footervar = "/home/chalchih/domains/chocolate-roses.frih.net/public_html/test/nav/footer";
    $extension = ".txt";
?>


This code then calls the correct header (basically the stylesheet link and menu) to include based on the skin that should be set. At this point the footer is the same for both skins, so I only include the default footer.txt at the bottom of each page.

Code:
<? include($headervar.$skin.$extension); ?>


A sample page code then looks like this:

Code:
<? include("cookiecheck.php"); ?>

<html>

<head>

<title>Chocolate Roses Cosplay</title>

<? include($headervar.$skin.$extension); ?>

<h1>Welcome!</h1>

<p>blahblahblahblah</p>

<? include('nav/footer.txt'); ?>


I'm really hoping someone can tell me what I'm messing up or missing and what I should do to fix it. Please help me!
mathiaus
Your currently setting a cookie on each page load. your first one sets it differently to the second creating a .chocolateroses.org one and a www.chocolate roses.org one, both with different values.
I've moved the ONE set_cookie which should be used so its only done when a user wants to choose a new skin. This should work assuming I haven't missed something else blindingly obvious.
Tidied it up my way as well sorry

Code:
<?

// CONFIGURATION
$total_skins = 2;
$default_skin = 1;
$headervar = "/home/chalchih/domains/chocolate-roses.frih.net/public_html/test/nav/header";
$footervar = "/home/chalchih/domains/chocolate-roses.frih.net/public_html/test/nav/footer";
$extension = ".txt";


// If user is requesting a new skin
if (isset($_GET['newskin'])) {
   // User their new choice of skin
   $skin = (int)$_GET['newskin'];
   // Validate skin choice
   if($skin < 1 || $skin > $total_skins) $skin = $default_skin;
   // Save their choice of skin in a cookie
   setcookie('skin', $skin, time()+(86400*365), '/', '.chocolate-roses.org');


// If user has a cookie defining a skin
} elseif(isset($_COOKIE['skin'])) {
   // Use their chosen skin (stored in cookie)
   $skin = (int)$_COOKIE['skin'];
   // Validate choice of skin
   if($skin < 1) || $skin > $total_skins) $skin = $default_skin;


// User has made no choise regarding skin
} else {
   // Use default skin
   $skin = $default_skin;
}

?>




EDIT: You may need to remove your existing cookies to check
EDIT 2: Do you really need to set it for a year?
scimitarmoon
Thank you so much! It works beautifully now!

There was an extra ) here:

Code:
   if($skin < 1) || $skin > $total_skins) $skin = $default_skin;


But I managed to figure that out and fix it all on my own. Thank you very much for your help!
mathiaus
scimitarmoon wrote:
There was an extra ) here:

Code:
   if($skin < 1) || $skin > $total_skins) $skin = $default_skin;

Bah! I always miss small things like that sorry.

Glad its working, good luck with your site Very Happy
-close-
Related topics
can i help?
help,Bonding
HELP!!
Help me with MySQL Account Maintenance and phpBB 2.0.15 :((
help, change pass my acc in cpanel
help me upgrade php to 5.
Need help adding a domain
help add admin in phpbb forum
How to solve this problem? Thanks
Help!
Help me change port for phptriad
X Arcade Version 1.0
Earn Money by Making Graphics
hey! i may need help if anyone knows about IPB stuff
This topic is locked: you cannot edit posts or make replies.    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.