You are not enjoying the benefits offered by registering. To register click here...
  
Forums | Prefs | Your Messages | Members | Recent | Search
Quick Search


Advanced Search
| Calendar | Doc | Dev' Blog! |
Chat (Alpha Version)

Guest, do not forget to login ( Register )
 Top > Forums > Just Talk > Whatever - Anything Goes
 A little PHP help

Skin Selection:
 (1 pages) 1  
Jasper

Public Speaker
Group: Testers
Posts: 562
Reputation: 10


Posted on Apr 28, 2005, 11:41 pm by Jasper
A little PHP help
On another site, I asked a question and was told this:

You could do something like having the images in different folders
(like "green", "red" etc) and just linking to them with something like
$dir/image.gif.


And they haven't said anymore since (few days ago).  When I asked for an example of what he was saying.  As I do have some idea of what he's saying, but don't know exactly how to code it.

_________________________________________________

I am using a style switcher coded in PHP for one of my personal sites.

My question is:  Certain images need to change with each styles that's being used.
Example:  I need the part in red to change with whatever style you're using
<td><img src='images/styles/default/top_left.gif' alt='' /></td>

I have 3 subdirectories in the "styles" subdirectory for the different styles:

images -> styles -> default
images -> styles -> black
images -> styles -> red

I need the part in red to change with each style that's being used.  So if you're using the red style, you'll see the images stored in the red directory.


Last edit by Jasper on Dec 31, 1969, 7:00 pm
doesn't come here often, cause he has no free time ;_;
 
Top

chris

The Culprit
Group: Admins
Posts: 1,532
Reputation: 38


Posted on Apr 29, 2005, 2:11 am by chris
Well, then assuming that you have your style name in, say, $mystyle, you would write:
Code:
<td><img src='images/styles/{$mystyle}/top_left.gif' alt='' /></td>

Actually, we may need to know more: is this code contained in an html page that you display from a php script?

Also, take a look at NBBS' common.php: I do a few tokens substitutions there.


 
Top

Jasper

Public Speaker
Group: Testers
Posts: 562
Reputation: 10


Posted on Apr 29, 2005, 6:44 am by Jasper
Ok, well this is everything.
**********************************
It's a simple code that only requires like 3 lines of code.

There is one files called switcher.php that contains this:
<?php
setcookie ('sitestyle', $set, time()+31536000, '/', 'eammm.com', '0');
header("Location: $HTTP_REFERER");
?>


Then between the <head> tags, I have this to call my CSS:
<style type="text/css">
@import url(<?php echo (!$sitestyle)?'defaultstyle':$sitestyle ?>.css);
</style>


I'm using a form to call a style to be used:
<form action="switcher.php" method="post">
<div>
<select name="set">
<option value="defaultstyle">Default</option>
<option value="black">Black</option>
<option value="red">Red</option>
</select>
<input type="submit" value="Change Style" />.
</div>
</form>


EVERY page on my site is a .php page.  There aren't any .html pages

Where I got the code from, was here

doesn't come here often, cause he has no free time ;_;
 
Top

 (1 pages) 1 - Flat Mode | Threaded Mode  
Quick Jump:

         
Page generated in 0.04 seconds (Queries: 0.00) - Cpu: 0.56
Total DB [adodb:mysql] queries: 15
Total Strings Translated: 13
Powered by NextBBS SE v0.4.5 - Copyright © 2007 CFR & The NextBBS Team
Chatbox powered by smiletag