04-27-2005, 08:39 AM | #1 (permalink) |
Loves my girl in thongs
Location: North of Mexico, South of Canada
|
[PHP] Calling an image using variables
I have a page that called brewery.php on my site. It's laid out in total CSS with PHP variable scripts. I call this page into a parent page using the include comand.
Thus, a typical address would be www.arch13.com/index.php?id=main where main is the nested page being called into the parent template index.php. Now I have a page called brewery.php that containes some new photography and I am looking at new ways of creating gallery's. The current PHP code being used on the page is: Code:
$id = $_REQUEST['id2']; if(file_exists($id.".jpg")) { echo "<img src='$id.jpg'>"; } elseif(file_exists($id.".php")) { include($id.".php"); } else { echo "<img src='brewerysplash.jpg'>"; } Is their a way to simplify this? What I'm looking for is a way to keep the url looking like www.arch13.com/index.php?id=brewery , and then have the id2= hidden, even though it was passed to get the picture it refrences. Perhaps like having brewery.php?id=1 where 1 is the first picture. Am I making any sense? The second question I suspect is easier. the images for brewery.php are named brewery_x.jpg where x is the number of the image in order. What code would allow id2=1 and call brewery_1.jpg? So that as the id # increased by 1, it just called the next image, assuming the brewery_ part? Is there a way to go about this that does not require hand coding the image name prefix (brewery_) into the php code, to make such a script usefull in multipule areas?
__________________
Seen on an employer evaluation: "The wheel is turning but the hamsters dead" ____________________________ Is arch13 really a porn diety ? find out after the film at 11. -Nanofever |
04-27-2005, 09:19 AM | #2 (permalink) | |
Insane
|
Quote:
As to your second question: Well, I'm not sure I understand the wording of the question correctly. Can you rephrase perhaps? Above all, please please please make sure you validate your id1 or id2 variables! I don't see it, but perhaps you do have some validating code, so forget the following if you do: If they're numbers, make sure they're numbers: use is_numeric(), is_float etc and perhaps if ($id1 > 0) to make sure it's not negative (if that's not what you're going for). If you don't, someone could easily craft a way to exploit your program. If you're going to be including PHP files, do something like this: Code:
$inc_files = array('main.php', 'blah.php'); if (in_array($id, $inc_files) == TRUE) { include($id); } else { include('default_page.php'); };
__________________
"You looked at me as if I was eating runny eggs in slow motion." - Gord Downie of The Tragically Hip |
|
04-27-2005, 09:46 AM | #3 (permalink) | |
Loves my girl in thongs
Location: North of Mexico, South of Canada
|
Quote:
If your talking about some other type of exploit possability, please explain what you mean. As for question 2; Take the page http://www.arch13.com/index.php?id=b...brewerycolor11 In that URL, I'm hating giving away my folder tree. I'd like to craft code that wil allow me to say id2=11 and have it call the image mentioned above, so that the user cannot see the image path as the variable, but only http://www.arch13.com/index.php?id=brewery&id2=11 instead. As for question 1; It's a moot point if question two can be answered in a way that address's hiding the directory tree.
__________________
Seen on an employer evaluation: "The wheel is turning but the hamsters dead" ____________________________ Is arch13 really a porn diety ? find out after the film at 11. -Nanofever |
|
04-27-2005, 11:20 AM | #4 (permalink) |
Darth Papa
Location: Yonder
|
...But you want to be able to bring in images from any directory? Is that it?
You could write a nested array of directories and then refer to the directories by array index. But that's sort of fugly. I suggest you use the oft-overlooked PATH_INFO field to pass the file location, rather than a query-string parameter. In the url: http://www.arch13.com/index.php/imgs...r11?id=brewery You should end up in index.php with: $_REQUEST[id] = "brewery" and $_SERVER[PATH_INFO] = "/imgs/brewery/brewerycolor11" It's still a lengthy URL, but it's not carying a ton of extra info in the QUERY_STRING, and it looks (except for that ".php" in there) like any old URL to a file or directory. PATH_INFO is great for hiding the fact that it's a dynamic page. I one time turned on CGI-EXEC on the root htdocs directory, put a Perl CGI in there called "pages", and called it with URLs like: http://www.site.com/pages/product/1234.html My "pages" script then spun out a page based on my "product" template with data from MySQL for item number "1234", and Google was none the wiser. |
04-27-2005, 12:20 PM | #5 (permalink) | ||
Loves my girl in thongs
Location: North of Mexico, South of Canada
|
Quote:
I don't mind having to change a variable in the php code when I create the new page to point to the correct image folder, I just don't want the huge varaibe url. So a php page for each place (Client), that corrisponds to a sub-folder in imgs/. I can change the varaible on each page I make, I just don't want to show all my data in the URL. Becuase the image is called using id2, I'd like to just name each image name_number and the script, having the imgs directory variable coded in when I made the page, would know that id2=1 means grab say stockhouse_1.jpg and diplay it in the image display area. Having variable two simply equal a number looks a lot cleaner. Bonus points if in doing this, there is a way to not show anything besides the first variable. I don;t mind index.php?id=blah&id2=1 for example, but being able to hide varaible two all together to create arch13.com/index/php?id-blah without showing the other variables would be awsome. As it may be obvious, I'm pretty clueless on varaible usage (or anything else) in PHP. Quote:
I don't want to show server paths at all. I just want arch13.com/index.php?id=blah where blah is the page they are at (This is how it currently works, allowing blah to just be a text file since it only needs to be parsed as part of the include) Looking at the url now, they go "Oh, I'm at the blah page of his site" since the format is easy to deduce. The idea is that on this page, the little red box is navigation, and when the right arrow is clicked, the image advances to the next image. Clicking the back arrow cuases the obvious effect. (No clue how I'm going to do this either, but I try to go one step at a time when learning) Not being trained in these things, I'm struggling to find the correct words to describe what I'm out for. Forgive me for being a little clueless.
__________________
Seen on an employer evaluation: "The wheel is turning but the hamsters dead" ____________________________ Is arch13 really a porn diety ? find out after the film at 11. -Nanofever |
||
04-27-2005, 02:33 PM | #6 (permalink) |
paranoid
Location: The Netherlands
|
Let me join in this with a question:
You need http://www.arch13.com/index.php?id=brewery&id2=12345 to turn into a "brewery" page with image number 12345? Or are you trying to hide id2 from the url and just show id=brewery ? EDIT: I think I get the fact that you want to simplify the URL to hide the paths, but it's ok to have both id= and id2= in the url. So I suggest (as posted by you earlier): http://www.arch13.com/index.php?id=brewery&id2=12345 The code should be something like this: PHP Code:
And you should validate your code as people could try to access your complete filesystem by requesting stuff like id=../../etc/passwd (Depending on system setup this might work).
__________________
"Do not kill. Do not rape. Do not steal. These are principles which every man of every faith can embrace. " - Murphy MacManus (Boondock Saints) Last edited by Silvy; 04-27-2005 at 02:47 PM.. |
04-27-2005, 02:40 PM | #7 (permalink) |
Darth Papa
Location: Yonder
|
If I were you, I'd make a record in MySQL for each image, and refer to an AUTO_INCREMENTing ID field in your $_REQUEST parameter. That's the simplest way I can think of to eliminate the complexity and filestructure-giveaway-ness of your current design. Maybe you could make yourself an upload page that would take the image, insert the record, and save the image to the appropriate directory?
|
04-27-2005, 06:46 PM | #8 (permalink) | |
Loves my girl in thongs
Location: North of Mexico, South of Canada
|
Quote:
The url would be www.arch13.com/index.php?id=brewery&id2=1 for the brewery page, displaying image 1. That's brilliant to use $_REQUEST['id'].'_'.$_REQUEST['id2'].'.jpg. How would this work into my current code? I think it's something like this: Code:
$id = $_REQUEST['id2']; define('IMAGE_PATH', 'img/'); $filename=$_REQUEST['id'].'_'.$_REQUEST['id2'].'.jpg' $image_location=IMAGE_PATH.$filename if(file_exists($id.".jpg")) { echo "<img src='$id.jpg'>"; } elseif(file_exists($id.".php")) { include($id.".php"); } else { echo "<img src='brewerysplash.jpg'>"; } It looks right, but I don't know. Guess I'll try it when I get home from studio. Thank you for understanding through my vague description! I'll report back as soon as I've tested it later tonight. (By the way, my server is set not to allow display of directories, so a file name would need to be guessed correctly to exploite the variable in the url, otherwise nothing would be displayed and the code would just insert the else when rendering the page.) Ratbastid, I don't have a database to use. I have mysql on the hosting package, but have never even set it up as that's an additonal layer of learning required, and I seem to be trying very little the needs this kind of stuff.
__________________
Seen on an employer evaluation: "The wheel is turning but the hamsters dead" ____________________________ Is arch13 really a porn diety ? find out after the film at 11. -Nanofever |
|
04-27-2005, 11:55 PM | #9 (permalink) | |
paranoid
Location: The Netherlands
|
Quote:
As for the code, no it's not completely correct. You are indeed using $_REQUEST['id2'] as you suggested (by calling it with $id), but not in the correct way (as it is now, your code would be looking for '1.jpg' and not 'img/brewery_1.jpg'). The code as (I think) it should be is this: (I've tried to use as much of your code as possible to help you understand what's going on. I also added comments, but if it's not completely clear, please do ask! Check this code against yours above to see the differences, I couldn't find a good way to display the differences...) Code:
/* Set up external variables */ $id = $_REQUEST['id']; $id2 = $_REQUEST['id2']; /* This is the place for the "optional" sanitizing of the variables you got from the URL */ /* Set up constants */ // Note, we're not using constants much, but it helps getting used to them define('IMAGE_PATH', 'img/'); // From now on we can use IMAGE_PATH, and it will substitute the string 'img/' for it. If you ever change the images directory, then changing this constant is enough for your entire code. /* setup complicated variables */ $filename=$id.'_'.$id2.'.jpg' // Since we defined $id / $id2 to be the URL variables before, we can use them. Saves typing, and makes it easier to read. $image_location=IMAGE_PATH.$filename // Becomes 'img/brewery_1.jpg' in our example /* program flow */ if(file_exists($image_location)) { // We already "built" the location variable, no need to do it again ;) echo "<img src='$image_location'>"; // Same here... } elseif(file_exists($id.".php")) { include($id.".php"); } else { echo "<img src='brewerysplash.jpg'>"; }
__________________
"Do not kill. Do not rape. Do not steal. These are principles which every man of every faith can embrace. " - Murphy MacManus (Boondock Saints) |
|
04-29-2005, 01:24 PM | #10 (permalink) | |
Loves my girl in thongs
Location: North of Mexico, South of Canada
|
Quote:
Here's how it's working (This will also address your first list point): Main page index.php contains the following: PHP Code:
The included page then has: PHP Code:
index.php has the script with $id = $_REQUEST['id'] in it, while whatever page is included has the php code for $id = $_REQUEST['id2']. That way, if a page included through id variable does not make use of id2, there is no id2 script in the included page. An example is my "main/about" page at www.arch13.com/index.php?id=main where the first script is in the template page that has all the tables (index.php), and the main.php page then has a script for id2 to call the left hand image. So I guess what I'm searching for is a way to keep the index.php script intact, and sinply pass the id variable onto the second script so it can use it as above for id2? Or would using your suggested page on the index.php page, and simply creating an anchor for id2 in any included page be more effeciant? Am I making any sense? hmmm. To put it another way, do I scrap the two scripts, on on each page with one for id and one for id2, and replace it with a single script on index.php, and create say echo ($id2.".jpg") on the brewery page where I want the image to be, or is it better to work with two php scripts, one on the index page addressing id, and one on whatever page id calls addressing id2? With that second option, could the needed information be passed between the two seperate scipts addressing id's 1&2 so that your suggested code could work if used in the brewery page? /Arch13's brain explodes
__________________
Seen on an employer evaluation: "The wheel is turning but the hamsters dead" ____________________________ Is arch13 really a porn diety ? find out after the film at 11. -Nanofever |
|
04-29-2005, 02:33 PM | #11 (permalink) |
paranoid
Location: The Netherlands
|
Ok, I had this really long response ready, and I re-read your post to see wether I got all your questions, and I got confused
Let's try to narrow down the issues a little index.php builds general page layout plus 1 of 3 things (load $id.jpg, load $id.php, load brewerysplash.jpg) correct? $id.php does what exactly? (and is it the same for every $id? i.e. brewery.php, stable.php, garage.php) (does it just echo a single image, or does it create buttons, or other stuff?) In order to try to answer some questions for you: - Can you call $_REQUEST['id2'] from within included files: yes - Can you call variables from index.php from within included files: yes - Can you disguise $_REQUEST['id2'] as $_REQUEST['id']: NO, or at least you shouldn't (but you can pass $id to the included files...) - Is it better to split the files or build one big index.php? I don't know (see my next post) Hope this will settle some questions, so we can get to the good stuff
__________________
"Do not kill. Do not rape. Do not steal. These are principles which every man of every faith can embrace. " - Murphy MacManus (Boondock Saints) |
04-29-2005, 02:39 PM | #12 (permalink) | |
paranoid
Location: The Netherlands
|
NOTE: READ THIS FIRST
I wrote this response to Arch13's previous post. I thought he was asking 2 questions: - Should I include files dynamically? - Is it possible for included files to use variables set in the URL? This response tries to tackle those questions. But re-reading his post, I wasn't sure he was asking for this So that's why I posted follow-up questions (my previous post). But in an effort to speed things along (and in case he indeed did ask for this reponse), I will now post the original reply I wrote. See this as more of an informational post, rather than continuing the discussion. End note I see your problem. (EDIT: I didn't ) Though using global variables should work on included pages. BUT..... why would you? What does the included page do? If the included page does the same thing everytime (i.e. display an image that the first script can guess itself), why would you include it, and not just build it in. IMHO including files can have the following reasons: - clearer code (large included libraries for example) - seperate authors. No need to include other's code because it makes debugging difficult - often-changing files (if the included files change often, or are perhaps changed by someone else) - code in the included files is not always needed. (as seems to be your case. You include files dynamically). Now the last point is only valid if the different included files (say brewery.php, stable.php, garage.php etc) vary in code or this difference in functionality is expected in the future If the code is predictable (as your quoted second file seems to be), why not put it into your main index.php? Your suggestion: Quote:
If, however, you still want / need to variably include files, and hence need to pass the $_REQUEST['id2'] parameter to the include file, you should not need to do much. On my installation this works out of the box. I just created 2 files (ugly code, but it works ) Save them in their suggested names, and try it out. One displays the value for 'id' (taken from the URL) and includes the second file. The second file prints the value of id2 which is also taken from the URL. In essence this proves that passing the values you need, works. First file: (include_test.php) PHP Code:
(included.php) PHP Code:
Code:
include test $_REQUEST[id] equals: foo Including file: Inluded file thinks $_REQUEST[id2] equals: bar passed including files Anyhow, unless your setup blocks it, passing URL variables to included files works automatically. (And so should so called 'global variables', so if you need to create a variable, you can "pass" it to included files as well. In fact, that's how my scripts usually load a bunch of settings, it includes a settings file which creates a whole bunch of global variables.) Note: indeed I forgot two semicolons in my previous code, so it didn't parse. The above code was copy/pasted from the working files so they should work
__________________
"Do not kill. Do not rape. Do not steal. These are principles which every man of every faith can embrace. " - Murphy MacManus (Boondock Saints) |
|
04-29-2005, 04:17 PM | #13 (permalink) | ||
Loves my girl in thongs
Location: North of Mexico, South of Canada
|
I'm going to take your posts one at a time, and the second post is going to be long as I'm going to include the html and php from my index page, and an example page that would be called as an include.
Quote:
I like that functionality, and it took a while to figure it out with lots of help. The else is just to put something (brewerysplash.jpg) up should they try to request something that does not exist. $id.php is whatever plaintext file I'm displaying in the templates content area. if you go to my front page, where brewerysplash.jpg is, that is the "content area". The point has always been seperating content from display. That way, many different types of content can be placed in that box based on what I want the viewer to see. Conversly, I can change the template, and not have to edit or change any of the included files. There are areas where we get complicated. In my portfolio for example. Index.php calls p_gallery into the content area using $id, and then p_gallery call's portfolio_gal.php through $id2 to build the thumbnail table. In this case, $id and $id2 have othing to with one another besides doing similar actions (calling in another file via include) Quote:
I'm not trying to disguise on as the other. I'm currently calling $_REQUEST['id2'] from the included file I caled using $id if I understand your first list point Can I use the $id variable from the index page in the included pages php script? That's what I was trying to ask in less well phrased questioning. So, On to the actual markup of index.php and brewery.php as maybe that will help you understand what I'm asking instead of me babbling
__________________
Seen on an employer evaluation: "The wheel is turning but the hamsters dead" ____________________________ Is arch13 really a porn diety ? find out after the film at 11. -Nanofever |
||
04-29-2005, 04:43 PM | #14 (permalink) |
Loves my girl in thongs
Location: North of Mexico, South of Canada
|
So here is my index.php:
Code:
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> <html> <head> <title>Arch13 Architecture and Tactile Design</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <meta name="description" content="Arch13 is a small design studio focused on Architectural Design and Historic Preservation. We like working with our hands and finding solutions that aren't just 'off the shelf'" /> <meta name="robots" content="ALL" /> <meta name="author" content="Arch13 Design Studio" /> <meta name="publisher" content="Arch13" /> <meta name="subject" content="Arch13 Design Studio" /> <meta name="title" content="Arch13" /> <link href="css/global.css" rel="stylesheet" media="screen" type="text/css"> <link href="css/type.css" rel="stylesheet" media="screen" type="text/css"> </head> <SCRIPT LANGUAGE="JavaScript" src="common/fadeitb.js"></SCRIPT> <SCRIPT LANGUAGE="JavaScript"> <!-- Idea by: Nic Wolfe (Nic@TimelapseProductions.com) --> <!-- Web URL: http://fineline.xs.mw --> <!-- This script and many more are available free online at --> <!-- The JavaScript Source!! http://javascript.internet.com --> <!-- Begin function popUp(URL) { day = new Date(); id = day.getTime(); eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=400,height=300,left = 312,top = 234');"); } // End --> </script> <body bgcolor="#181A25"> <table width="700" height="408" border="0" align="center" cellpadding="0" cellspacing="0" style="border:1px solid #FFFFFF; width: 698px;"> <tr bgcolor="#FFFFFF"> <td width="28" height="25" bgcolor="#999999" class="navbars" cellpadding="0" cellspacing="0"> </td> <td width="201" bgcolor="#999999" class="navbars" cellpadding="0" cellspacing="0"><font color="#FFFFFF"><a href="index.php" class="masthead">Arch13.com</a></font></td> <td width="439" height="25" bgcolor="#999999" class="navbars" cellpadding="0" cellspacing="0"><div align="right">Bryce | Sonia</div></td> <td width="28" bgcolor="#999999" class="navbars" cellpadding="0" cellspacing="0"> </td> </tr> <tr bgcolor="#FFFFFF"> <td height="25" class="navbars" cellpadding="0" cellspacing="0"> </td> <td height="25" class="navbars" cellpadding="0" cellspacing="0">Architecture/Design</td> <td height="25" class="navbars" cellpadding="0" cellspacing="0"><div align="right"><a href="index.php?id=main">About</a> | <a href="index.php?id=recent">Recent Work</a> | <a href="index.php?id=contact">Contact</a> | <a href="index.php?id=resume">Resumé</a> | <a href="index.php?id=p_gallery&id2=portfolio_gal">Portfolio</a></div></td> <td height="25" class="navbars" cellpadding="0" cellspacing="0"> </td> </tr> <tr> <td height="353" bgcolor="#CCCCCC"><div align="center" class="unnamed2"> <p> </p> </div></td> <td height="353" colspan="2"cellpadding="0" class="contentbox"><div align="center"> <?php $id = $_REQUEST['id']; if(file_exists($id.".jpg")) { echo "<img src='$id.jpg'>"; } elseif(file_exists($id.".php")) { include($id.".php"); } else { echo "<img src='Brewerysplash.jpg'>"; } ?> </div> <div align="center"></div></td> <td bgcolor="CCCCCC"> </td> </tr> </table> <div align="center" class="footer"><br> <A HREF="javascript:popUp('popup_copyright.php')" class="footer"> <?php include"footer.htm"; ?> </A> </div> </body> </html> Now brewery.php: Code:
<link href="css/global.css" rel="stylesheet" type="text/css" /> <link href="css/layout.css" rel="stylesheet" type="text/css" /> <style type="text/css"> <!-- .wrapper { height: 480px; width: 640px; margin:0px auto; text-align:center; padding-top:0px; border:1px #fff; } .photo_image { height: 440px; margin: 0 0 0 0px; background-color:#BFCCE3; remove---> font-family: Verdana; font-size: 11px; } .photo_nav { height: 40px; margin:0 0 0 0px; text-align:left; padding:0px 0px 0px 5px; border-top:2px solid #ccc; background-color:#666; font-family: Verdana; font-size: 11px; } .photo_subnav { width: 55px; height: 40px; background-color:#660000; padding:0px 0px 0px 0px; float: left; color: #FFFFFF; } --> </style> <div class="wrapper"> <div class="photo_image"> <?php $id = $_REQUEST['id2']; if(file_exists($id.".jpg")) { echo "<img src='$id.jpg'>"; } elseif(file_exists($id.".php")) { include($id.".php"); } else { echo "<img src='brewerysplash.jpg'>"; } ?> </div> <div class="photo_nav"> <div class="photo_subnav">< 1/12 ></div> Crasnton, RI - Built in 1853 as the Providence Trolley house. Used as the repair shop and storage shed for trolleys until 1923 when the city shuttered their traction car system. It was then converted to the Cranston Brewery under which it operated until the company went under in the late 70's.</div> </div> The solution I'm searching for is something to use on all the building gallery pages. Brewery.php, stockhouse.php, etc. So the url www.arch13.com/index.php?id=brewery will display the brewery.php file in the content box of the index. Becuase I still need the code to work in way similar to currently on some pages, while the way we're discussing on others, I thought keeping the $id and $id2 scripts seperate was a good idea. But I know a lot less about clean code than you do. I want to create a new set of pages, one for each building I document. On these pages, the solution I want is what we are discssuing. So to comment on your script as suggested: Code:
$id = $_REQUEST['id']; //Can't we just get this from the script in index.php since that already defined it? $id2 = $_REQUEST['id2']; define('IMAGE_PATH', 'img/'); // Okay, I understand that this allows the code to place imgs/ in front of the image path $filename=$id.'_'.$id2.'.jpg' // Since we defined $id in the parent page (index.php), how to we pass it on to this php script on the included page? $image_location=IMAGE_PATH.$filename // Becomes 'img/brewery_1.jpg' in our example. That's exactly what I was thinking of. if(file_exists($image_location)) { echo "<img src='$image_location'>"; // So this is what displays the picture dependong on the variable.. } elseif(file_exists($id.".php")) { include($id.".php"); } else { echo "<img src='brewerysplash.jpg'>"; } I really hope not Can your suggested script be made to work while leaving the php script in index.php the same and just messing with the php script on the included page, or is this going to take a whole new appraoch?
__________________
Seen on an employer evaluation: "The wheel is turning but the hamsters dead" ____________________________ Is arch13 really a porn diety ? find out after the film at 11. -Nanofever |
04-29-2005, 05:42 PM | #15 (permalink) | ||||||||||
paranoid
Location: The Netherlands
|
Warning, read the entire post, answer the last part first, it'll probably be the most relevant.
Quote:
Quote:
1 content ($id.php) 1 mostly structure (index.php) 1 layout, color etc (css) Quote:
Quote:
Quote:
Actually for that first list point I meant that $_REQUEST['id2'] should not be put into a variable $id if there is no specific reason. Because when you read through your code later, you might mistake $id coming from $_REQUEST['id']. I usually try to name my variables logically to make the code easier to understand. Ofcourse if a script depends on the existance of $id. And the value for it is located in $_REQUEST['id2'], by all means do that. On to the next post: Quote:
Quote:
Where is brewery.php located? (and if you had a choice, where do you want it to be after we're done?) - in www/ - in www/brewery - in www/imgs/brewery The reason I'm asking is that it looks like all files are currently in the same directory. (judging by a quick glance through the code). Then again, you mentioned paths in your URLs before, so this is indeed a problem we need to tackle. Apparently your index.php is in (say) www/ your images are in www/brewery/ (ex. www/brewery/brewery1.jpg) Since we're hiding the path now, we need to decide where you want the middle-man (brewery.php, which essentially is the second file in the include-chain). I'd suggest: index.php does a file_exists('brewery.jpg') (so local to the index.php) index.php then does a file_exists('brewery/brewery.php') (so in a sub-dir from index.php) (and then the splash) brewery.php looks in it's local directory for the images. brewery.php looks in a subdir for the include (and then the splash) etc. Quote:
I think you'll find the above set up of file locations to be a good step towards your goal. Note, about the code, I wrote the script to replace the code in index.php (hence some confusion there. This was my fault, as I thought it would reference the images directly. ) Given the mix-up, all your comments are correct. Quote:
Quote:
With the above set up we can leave most of the files the way they are. To be absolutely compatible with the current situation (but migrate to the file setup I mentioned earlier) change this in index.php: Code:
$id = $_REQUEST['id']; if(file_exists($id.".jpg")) { echo "<img src='$id.jpg'>"; } elseif(file_exists($id.".php")) { include($id.".php"); } else { echo "<img src='Brewerysplash.jpg'>"; } Code:
$id = $_REQUEST['id']; if(file_exists($id.".jpg")) { echo "<img src='$id.jpg'>"; } elseif( file_exists( $id."/".$id.".php" ) { include( $id."/".$id.".php" } elseif(file_exists($id.".php")) { include($id.".php"); } else { echo "<img src='Brewerysplash.jpg'>"; } This checks wether a subdirectory exists with a php file. Now all images are in www/brewery right? put the brewery.php in there as well. If the images in www/brewery are called brewery1.jpg and so on change Code:
$id = $_REQUEST['id2']; if(file_exists($id.".jpg")) { echo "<img src='$id.jpg'>"; } elseif(file_exists($id.".php")) { include($id.".php"); } else { echo "<img src='brewerysplash.jpg'>"; } Code:
$base = 'brewery'; //only for images if they are called brewery1.jpg etc. $id = $_REQUEST['id2']; if(file_exists($base.$id.".jpg")) { echo "<img src='$base.$id.jpg'>"; } elseif(file_exists($id.".php")) { include($id.".php"); } else { echo "<img src='brewerysplash.jpg'>"; } (if the images in www/brewery are called 1.jpg, 2.jpg etc you can leave the code as-is). It should then work. (forgetting all those things about coding practices, constants and other stuff, let's get it to work first ) Then we'll clean up the code. This way, if I'm correct, all should work the same as it is now but for brewery. Brewery can now use shorter URLs http://www.arch13.com/index.php?id=brewery&id2=1 should load up the page through index.php, which looks for brewery/brewery.php and includes it. Brewery.php then looks for brewery1.jpg, finds it and echo's the corresponding HTML. Are we getting somewhere? Btw, if there is a maximum post size on this forum, we should be reaching it pretty soon
__________________
"Do not kill. Do not rape. Do not steal. These are principles which every man of every faith can embrace. " - Murphy MacManus (Boondock Saints) |
||||||||||
04-29-2005, 10:32 PM | #16 (permalink) | |||||
Loves my girl in thongs
Location: North of Mexico, South of Canada
|
Last question first?
Your right, where getting close to the post size limit Actually, big question's answer is we are definiatly getting somewhere You are speaking in ways that make me sure you are understanding my strange questions. I tried the code at the end ( www.arch13.com/index.php?id=brewery_test&id2=1 ) It doesn't work becuase the php file and images are in different folders. I'll address that in this post in a minute. Now on to my befuddled responses. Quote:
what do you mean by special variable? Is there another way than just using id and id2 like I'm doing? It's clean and simply currently, but I'm always for less complication. Quote:
right now brewery.php is also there. I don't like that. I want it to be in www/brewery with the images in www/imgs/brewery (I like having all images in a single folder for clarity) images have always been there throughout our posts. This is part of my "don't show the path question". How to have the images and php file in different folders without making long file paths out of the $id variables in the url. Right now you'd have to type http://www.arch13.com/index.php?id=b...imgs/brewery_1 to see an image. That drives me crazy that the $id2 variable shows the file path to the image. That's why I'm looking to make it just $id2=12345 instead. Quote:
index.php in www/ brewery.php in www/brewery (we give it it's own folder becuase there is other data about the brewery that also needs to be grouped together. For example, a Plaintext page of historic data on the building that may be displayed as an include in index.php instead. Keeping like files together is the goal) images in www/imgs/brewery So I guess that what needs to happen is: index.php does a file_exists ('brewery.php') index.php then does a file exists ('brewery/brewery.php') (Then the splash) Brewery.php looks in a www/imgs/same name as php file for it's images (and then the splash) Quote:
The images are named as follows: brewery_x.jpg with x as the image number. In this case, saying $base = 'brewery_' would do the same thing but add the underscore, right? Your code for index.php I understand completly. It accounts for each building having it's own folder of the same name as the page. The code for the image display isn't correct though. As I mentioned above, the images are in www/imgs/brewery, not www/brewery. So the images and php file are in seperate directories. (The splash image is the only one I keep in the root) when this gallery works, I'll create a splash image for this gallery to defualt to and place it in the www/imgs/brewery folder as well. Quote:
So my next question is how do we account for brewery.php not being in the same folder as the images? I assume we need to change the if(file_exists($base.$id.".jpg")) statment to reflect that it needs to check www/imgs/brewery for the files existance instead. Would it be if(file_exists(imgs/$base.$id.".jpg")) then?
__________________
Seen on an employer evaluation: "The wheel is turning but the hamsters dead" ____________________________ Is arch13 really a porn diety ? find out after the film at 11. -Nanofever |
|||||
04-30-2005, 01:39 AM | #17 (permalink) | ||||||
paranoid
Location: The Netherlands
|
Not being disrespectful, but this is a case where the last part really is the most important so I removed most of the quote to get to the good stuff :
Quote:
What we need is it to look for 1 directory higher than itself. This can be done in one of 3 ways: By using the full path of the file (so it looks for an absolute path, instead of a relative path.) (file_exists("/var/www/localhost/http/whatever/www/img/brewery_1.jpg") By using a relative path, but to look one dir higher (file_exists("../imgs/brewery_1.jpg") By using a global directive to point to the file locations. This one should be relatively easy to grasp so we're going to do this the most elegant way (via the global constant). Since all images are always located in www/imgs let's have index.php set the image_path constant: (put this in the top-section of index.php, makes it easier to find later) PHP Code:
PHP Code:
Does it work now? Now, on to the rest of your post: Quote:
In response to my question: Quote:
Quote:
index.php could set up a variable $included_file_parameters, which could then be read by whichever file is included (in our current code index.php would execute $included_file_paramters=$_REQUEST['id2']). This is neater (in my opinion) and more maintainable. But, for now, we should leave it as-is. Quote:
Quote:
I think we should have a working page now.
__________________
"Do not kill. Do not rape. Do not steal. These are principles which every man of every faith can embrace. " - Murphy MacManus (Boondock Saints) Last edited by Silvy; 04-30-2005 at 01:49 AM.. |
||||||
04-30-2005, 02:36 PM | #18 (permalink) | |
Loves my girl in thongs
Location: North of Mexico, South of Canada
|
Quote:
I see two problems going on here, and I'm trying to see how we can fix them. The first is actually straight foreward, but I almost didn't spot it. We can't have $base= "brewery_"; like I suggested. It needs to be just "brewery" since the base statment is also used for finding the paths. Throwing in the underscore to makes the images work but makes the file paths not work. Perhaps file_exists(IMAGE_FS_PATH.$base._$id.'jpg'; But that screws up the code (I tried it). It parse errors like so: Parse error: parse error, unexpected T_VARIABLE in /homepages/6/d93661089/htdocs/brewery_test.php on line 52 Line 52 was if(file_exists(IMAGE_FS_PATH.$base._$id.'jpg'; )) { , so that was a bad idea on my part to try. Honestly, It's simplest for me to just change the image names to brewery1.jpg, since that should make the code work. I'll try it right now before continuing this post... Nope Okay, here are lines 49-59 of brewery.php that don't want to co-operate PHP Code:
PHP Code:
The system path is correct, as the php install is supposed to see my / as the root and works in all instances I've used it as such. It's not parse erroring, brewery_test is, so I assume it's working fine. I have two copies of every image in the /imgs/brewery folder. One of each named brewery_1.jpg and one of each named brewery1.jpg. The file_exists is seeing neither right now. Any suggestions? The file I have been playing with is www.arch13.com/index.php?id=brewery_test
__________________
Seen on an employer evaluation: "The wheel is turning but the hamsters dead" ____________________________ Is arch13 really a porn diety ? find out after the film at 11. -Nanofever |
|
04-30-2005, 03:13 PM | #19 (permalink) | |||||
paranoid
Location: The Netherlands
|
Quote:
I see the folllowing path info needed at some point: - the path to the images (in brewery.php), this is set via the constant. $base, has no influence on that - the path to brewery.php (in index.php), this is built out of $id= $_REQUEST['id'], $base has got nothing to do with it. - the actual filename of the image. $base is used here, but not for the path, only for the image name. IMAGE_FS_PATH and IMAGE_WWW_PATH are used to get the directory structure. So we build the full image path/name out of the following compontents: constant: IMAGE_FS_PATH (= '/imgs/') variable: $base (='brewery_') variable: $id (='1'); string: '.jpg' concatenating to: '/imgs/brewery_1.jpg' right? Quote:
file_exists(IMAGE_FS_PATH.$base.'_'.$id.'jpg'; (but this is not necessary now, as $base can just contain the underscore) Quote:
Try setting IMAGE_FS_PATH to the real filesystem path. (i.e. /var/www/etc) this is needed on my setup, but it could very well different on yours. Quote:
I usually put them at the very top of my php files, as a sort of initialization. But so long as they're defined before they're used, it's fine Quote:
I'm not sure what you mean by 'supposed to see my / as the root'. Try setting IMAGE_FS_PATH to the FULL system path '/var/www/htdocs/whatever/' and set IMAGE_WWW_PATH to 'img/' (in the define statements in index.php) (include the trailing slash on both constants) Post the contents of index.php and brewery.php again, and any parse errors you got but couldn't fix. I think we're down to a few typos here or there. (mainly in the paths or image names) Btw: I see a unexpected T_CONSTANT_ENCAPSED_STRING error on your test page, check the line (53) for unmatched quotes (' or ") or a missing semi-colon( ; ) the semi-colon could also be missing on line 52. Another note: the code above should be outputting HTML looking for images in http://www.arch13.com/imgs/brewery_1.jpg (and so on). But looking for that URL gives me 404 errors. If the above URL should be correct, you might need to fix that first. If this URL to the image is not supposed to be correct, the code above needs fixing
__________________
"Do not kill. Do not rape. Do not steal. These are principles which every man of every faith can embrace. " - Murphy MacManus (Boondock Saints) |
|||||
05-01-2005, 12:16 PM | #20 (permalink) | |||||
Loves my girl in thongs
Location: North of Mexico, South of Canada
|
Quote:
I was under the impression that we were doing /imgs/$base/$base_12345.jpg as our formula. This is most likely my mistake in understanding. Also, this is where we are going wrong and the script is dying. The images are located in /imgs/brewey/brewery_1.jpg. Each building has an image folder in /imgs/ , and a folder for their .php file and other info files in /. For now, the brewery.php is just in the local root, and that shouldn't be a problem for what we're doing. If that is causing a problem, let me know and I'll get on creating the /brewery folder for the files already. Brewery images brewery_1.jpg through brewery_12.jpg are all located in /imgs/brewery/. Quote:
"Syntax, syntax, syntax!" Quote:
Quote:
I played around trying to edit and understand through experimentation when I got the parse errors, so it's probably all types of screwed up now. Quote:
Thanks for your patience on this Silvy, have I mentioned you kick ass? (But ohhhh, wait till you see my next silly question ) Index.php: Code:
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN"> <html> <head> <title>Arch13 Architecture and Tactile Design</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <meta name="description" content="Arch13 is a small design studio focused on Architectural Design and Historic Preservation. We like working with our hands and finding solutions that aren't just 'off the shelf'" /> <meta name="robots" content="ALL" /> <meta name="author" content="Arch13 Design Studio" /> <meta name="publisher" content="Arch13" /> <meta name="subject" content="Arch13 Design Studio" /> <meta name="title" content="Arch13" /> <link href="css/global.css" rel="stylesheet" media="screen" type="text/css"> <link href="css/type.css" rel="stylesheet" media="screen" type="text/css"> </head> <SCRIPT LANGUAGE="JavaScript" src="common/fadeitb.js"></SCRIPT> <SCRIPT LANGUAGE="JavaScript"> <!-- Idea by: Nic Wolfe (Nic@TimelapseProductions.com) --> <!-- Web URL: http://fineline.xs.mw --> <!-- This script and many more are available free online at --> <!-- The JavaScript Source!! http://javascript.internet.com --> <!-- Begin function popUp(URL) { day = new Date(); id = day.getTime(); eval("page" + id + " = window.open(URL, '" + id + "', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0,width=400,height=300,left = 312,top = 234');"); } // End --> </script> <?php define ('IMAGE_FS_PATH', '/img/'); //full filesystem path to your images define ('IMAGE_WWW_PATH', 'img/'); //this should be the path relative to the URL ?> <body bgcolor="#181A25"> <table width="700" height="408" border="0" align="center" cellpadding="0" cellspacing="0" style="border:1px solid #FFFFFF; width: 698px;"> <tr bgcolor="#FFFFFF"> <td width="28" height="25" bgcolor="#999999" class="navbars" cellpadding="0" cellspacing="0"> </td> <td width="201" bgcolor="#999999" class="navbars" cellpadding="0" cellspacing="0"><font color="#FFFFFF"><a href="index.php" class="masthead">Arch13.com</a></font></td> <td width="439" height="25" bgcolor="#999999" class="navbars" cellpadding="0" cellspacing="0"><div align="right">Bryce | Sonia</div></td> <td width="28" bgcolor="#999999" class="navbars" cellpadding="0" cellspacing="0"> </td> </tr> <tr bgcolor="#FFFFFF"> <td height="25" class="navbars" cellpadding="0" cellspacing="0"> </td> <td height="25" class="navbars" cellpadding="0" cellspacing="0">Architecture/Design</td> <td height="25" class="navbars" cellpadding="0" cellspacing="0"><div align="right"><a href="index.php?id=main">About</a> | <a href="index.php?id=recent">Recent Work</a> | <a href="index.php?id=contact">Contact</a> | <a href="index.php?id=resume">Resumé</a> | <a href="index.php?id=p_gallery&id2=portfolio_gal">Portfolio</a></div></td> <td height="25" class="navbars" cellpadding="0" cellspacing="0"> </td> </tr> <tr> <td height="353" bgcolor="#CCCCCC"><div align="center" class="unnamed2"> <p> </p> </div></td> <td height="353" colspan="2"cellpadding="0" class="contentbox"><div align="center"> <?php $id = $_REQUEST['id']; if(file_exists($id.".jpg")) { echo "<img src='$id.jpg'>"; } elseif(file_exists($id.".php")) { include($id.".php"); } else { echo "<img src='Brewerysplash.jpg'>"; } ?> </div> <div align="center"></div></td> <td bgcolor="CCCCCC"> </td> </tr> </table> <div align="center" class="footer"><br> <A HREF="javascript:popUp('popup_copyright.php')" class="footer"> <?php include"footer.htm"; ?> </A> </div> </body> </html> Code:
<link href="css/global.css" rel="stylesheet" type="text/css" /> <link href="css/layout.css" rel="stylesheet" type="text/css" /> <style type="text/css"> <!-- .wrapper { height: 480px; width: 640px; margin:0px auto; text-align:center; padding-top:0px; border:1px #fff; } .photo_image { height: 440px; margin: 0 0 0 0px; background-color:#BFCCE3; remove---> font-family: Verdana; font-size: 11px; } .photo_nav { height: 40px; margin:0 0 0 0px; text-align:left; padding:0px 0px 0px 5px; border-top:2px solid #ccc; background-color:#666; font-family: Verdana; font-size: 11px; } .photo_subnav { width: 55px; height: 40px; background-color:#660000; padding:0px 0px 0px 0px; float: left; color: #FFFFFF; } .spacer { background-color:#666; width: 10px; height: 40px; float:left; } --> </style> <div class="wrapper"> <div class="photo_image"> <?php $base = 'brewery_'; //only for images if they are called brewery1.jpg etc. $id = $_REQUEST['id2']; if(file_exists(IMAGE_FS_PATH.$base.$id.'jpg')) { //this expands into '/var/www/img/brewery_1.jpg echo "<img src='".IMAGE_WWW_PATH.$base.$id'.jpg'>"; this expands into imgs/brewery_1.jpg, which will allow the browser to find it relative to "http://www.arch13.com" } elseif(file_exists($id.".php")) { include($id.".php"); } else { echo "<img src='brewerysplash.jpg'>"; } ?> </div> <div class="photo_nav"> <div class="photo_subnav">< 1/12 ></div> Crasnton, RI - Built in 1853 as the Providence Trolley house. Used as the repair shop and storage shed for trolleys until 1923 when the city shuttered their traction car system. It was then converted to the Cranston Brewery under which it operated until the company went under in the late 70's.</div> </div> Added www.arch13.com/phpinfo.php . Take a look if you need any of that info. My path looks to be /homepages/6/d93661089/htdocs on the server.
__________________
Seen on an employer evaluation: "The wheel is turning but the hamsters dead" ____________________________ Is arch13 really a porn diety ? find out after the film at 11. -Nanofever Last edited by arch13; 05-01-2005 at 12:24 PM.. |
|||||
05-02-2005, 03:56 AM | #21 (permalink) | ||
paranoid
Location: The Netherlands
|
Quote:
So $base is indeed necessary to find the path in /imgs/ we will need to use it twice. Once for the path, once for the filename, as you suggested earlier. Quote:
(and don't hesitate to post silly questions, but if there too silly post them in Tilted Nonsense ) Ok, we have still have the following issues: - the /imgs/brewery/ lookup - the fact that brewer_test.php has a different name than what index.php is looking for - the fact that even though we want to have brewery.php in a seperate dir, it isn't now. Let's solve the last 2 first: (I understand you want to keep your current brewery.php as a backup, so we'll work around it) - make a new dir www/brewery (for all your non-image brewery files) - copy brewery_test.php to that dir and name it brewery.php Add 2 lines to index.php: Code:
$id = $_REQUEST['id']; if(file_exists($id.".jpg")) { echo "<img src='$id.jpg'>"; } elseif(file_exists($id.'/'.$id.'.php')){ //add this line include($id.'/'.$id.'.php'); //add this line too } elseif(file_exists($id.".php")) { include($id.".php"); } else { echo "<img src='Brewerysplash.jpg'>"; } That should at least allow index.php to find brewery/brewery.php and fall back to /$id.php for all others Now to look up the correct images: Change the following line in index.php: Code:
define ('IMAGE_FS_PATH', '/homepages/6/d93661089/htdocs/img/'); Change some lines here: Code:
$base = 'brewery'; //CHANGED (removed _ ) $id = $_REQUEST['id2']; if(file_exists(IMAGE_FS_PATH.$base.'/'.$base.'_'.$id.'jpg')) { //CHANGED added $base.'/'. and .'_' echo "<img src='".IMAGE_WWW_PATH.$base.'/'.$base.'_'.$id.".jpg'>"; //CHANGED added same as the line above, watch for correct quotes! } elseif(file_exists($id.".php")) { include($id.".php"); } else { echo "<img src='brewerysplash.jpg'>"; } Ok, I wonder what the effect of these changes is.
__________________
"Do not kill. Do not rape. Do not steal. These are principles which every man of every faith can embrace. " - Murphy MacManus (Boondock Saints) |
||
05-02-2005, 10:46 AM | #22 (permalink) |
Loves my girl in thongs
Location: North of Mexico, South of Canada
|
Ya know, are you a teacher Silvy? You should be.
This url still isn't working though: http://www.arch13.com/index.php?id=brewery&id2=11 I killed off the brewery.php in the local root, so we know that your new lines in the index.php did the trick. It's looking in /brewery for the page when given $id=brewery. So now it's down to a single problem I guess. I changed the image paths in the begining of index.php to: Code:
define ('IMAGE_FS_PATH', '/homepages/6/d93661089/htdocs/imgs/'); //full filesystem path to images define ('IMAGE_WWW_PATH', 'imgs/'); // path relative to the URL The code in brewery.php itself looks like this: Code:
$base = 'brewery'; //CHANGED (removed _ ) $id = $_REQUEST['id2']; if(file_exists(IMAGE_FS_PATH.$base.'/'.$base.'_'.$id.'jpg')) { //CHANGED added $base.'/'. and .'_' echo "<img src='".IMAGE_WWW_PATH.$base.'/'.$base.'_'.$id.".jpg'>"; //CHANGED added same as the line above, watch for correct quotes! } elseif(file_exists($id.".php")) { include($id.".php"); } else { echo "<img src='brewerysplash.jpg'>"; } My question is, why isn't $id2 showing brewery_11.jpg in the url I gave at the begining of htis post? It seems as the though the problem is with the image paths in some way.
__________________
Seen on an employer evaluation: "The wheel is turning but the hamsters dead" ____________________________ Is arch13 really a porn diety ? find out after the film at 11. -Nanofever |
05-02-2005, 11:13 AM | #23 (permalink) | ||
Insane
|
Quote:
Quote:
Use the var_dump(), print_r() functions at any point in time to see the contents of a variable. It may help.
__________________
"You looked at me as if I was eating runny eggs in slow motion." - Gord Downie of The Tragically Hip Last edited by trache; 05-02-2005 at 11:17 AM.. |
||
05-02-2005, 11:27 AM | #24 (permalink) | |
Loves my girl in thongs
Location: North of Mexico, South of Canada
|
Quote:
Works perfectly now! Awsome So my next question is just a genral question. (I told you this was comming Silvy ) On that page there is a red box with <1/12> I think why that's there is pretty straightforward. I want to figure how using php and javascript, I can use that to scroll through the images. I suspect that a combo of php and swap.js to change the numbers is the way to go, but I always want opinions when getting in over my head I figure that I can create 12 gifs, 1/12, 2/12, etc in the font I like that is not web freindly, and have swap.js swap them out as needed. The question is, how to create a system that allows the user the see the images using php?
__________________
Seen on an employer evaluation: "The wheel is turning but the hamsters dead" ____________________________ Is arch13 really a porn diety ? find out after the film at 11. -Nanofever |
|
05-02-2005, 11:49 AM | #25 (permalink) | |||
paranoid
Location: The Netherlands
|
Quote:
Quote:
What I would do, personally, is: in brewery.php: - find out how many pictures there are in the gallery (/imgs/brewery/) - load a list of them in Javascript - display < current_id / total_number > in the lower left corner. - attach eventhandlers to the left and right brackets (< >) Those (javascript) eventhandlers will replace the image with the previous and next images respectively. I don't really see a neat way of doing the < 1/12 >, 2/12, 3/12 etc with image files though, either it's a lot of hassle doing it dynamically via PHP (create the image files on-the-fly) or force every gallery to have at least, and at most 12 images. With my setup it doesn't do image pre-loading, meaning the browser will not download the image until it is needed, causing a delay between the click and the showing of the image. (Perhaps swap.js is supposed to pre-load images?) I know image pre-loading is possible, I just haven't looked into it. Quote:
__________________
"Do not kill. Do not rape. Do not steal. These are principles which every man of every faith can embrace. " - Murphy MacManus (Boondock Saints) Last edited by Silvy; 05-02-2005 at 12:21 PM.. |
|||
05-02-2005, 08:18 PM | #26 (permalink) |
Insane
|
Perhaps it's just me, but a vast number of people surf with JavaScript turned off for security reasons if not for annoying tricks webmasters play with JavaScript.
Consider trying to use some form of CSS to roll the images.
__________________
"You looked at me as if I was eating runny eggs in slow motion." - Gord Downie of The Tragically Hip |
05-03-2005, 09:39 PM | #27 (permalink) |
Loves my girl in thongs
Location: North of Mexico, South of Canada
|
Well the most important thing is trying to make the <>'s work.
The idea being that a script is used that gives the $id2 list of images as an array ($id2=1-12), such that each click of > adds +1 to the $id2 and every < does -1. It seems equally possible in javascript and php, The whole display the # image thing is secondary. I'm also going to keep looking around for scripts that already do this in some way that may deliver a solution. Given the framework we set up in this thread (Which is very important to me ), what suggestion might anyone have about how to integrate the ability to navigate through the buttons? Also, Trache, How could this be acheived through CSS while fiting into the framework of $id2=1 calls brewery_1.jpg? I'm real interested in that if it's a funtional possibility that can interact with the url variable framework.
__________________
Seen on an employer evaluation: "The wheel is turning but the hamsters dead" ____________________________ Is arch13 really a porn diety ? find out after the film at 11. -Nanofever |
05-04-2005, 02:54 AM | #28 (permalink) |
Insane
|
You could write the CSS file and link it inside your webpage dynamically, or you could write the styles out dynamically when and where you need them.
I believe there are a a:hover , a:visited, a, etc selectors that you could apply to an HREF that change its behaviour. It's just a thought though. You may want JavaScript to be enabled before anyone could use the site; ultimately it's up to you.
__________________
"You looked at me as if I was eating runny eggs in slow motion." - Gord Downie of The Tragically Hip |
05-04-2005, 03:20 AM | #29 (permalink) |
paranoid
Location: The Netherlands
|
As far as I know CSS is not meant for, nor capable of modifying, activating or defining URL's Meaning that CSS cannot be used to run through the images.
CSS is used to define styles, HTML is used to define structure, and you need a programming language to do anything but the most basic functionality. So either JavaScript, Flash, PHP, etc Note: I think Trache meant that CSS can be used to insert an image (statically) into a page (for example, a background for the body, or a table). CSS cannot however change the image once it is there. To change the image, you need to reload the page, with a CSS file that uses a different image in the same place. Personally, I think that this is not such a nice way of switching images. /end Note I agree with Trache's comments on javascript security and common annoyances, but I don't know what the statistics are for users with javascript enabled/disabled. To be most compatible, a server-side solution is best. In your case: generating all pages with PHP. Brewery.php would then compose a list of all images, output the page with the current image (id2), and depending on where that image is in the list, display the x/12 and < > things. The brackets < > would then directly link back to a new page with id2+1 or id2-1. The downside compared to JavaScript is the fact that the complete page will be reloaded for each image. The plus side is that all gallery logic is server-side and in the same language, making maintenance/debugging etc easier.
__________________
"Do not kill. Do not rape. Do not steal. These are principles which every man of every faith can embrace. " - Murphy MacManus (Boondock Saints) |
05-05-2005, 06:54 PM | #30 (permalink) | |
Loves my girl in thongs
Location: North of Mexico, South of Canada
|
Quote:
I guess I should start a new thread (or not if we're still going for longest single post records ) Is this a realitively easy approach? I don't mind the server load since the site does not have heavy traffic. I'm more concerened with good presentation and good code that can be used long term. How do I go about this (Arch13 figures he may be getting some sort of bill from Silvy soon )
__________________
Seen on an employer evaluation: "The wheel is turning but the hamsters dead" ____________________________ Is arch13 really a porn diety ? find out after the film at 11. -Nanofever |
|
Tags |
calling, image, php, variables |
|
|