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:
Originally Posted by Silvy
This gets interesting. Do you want p_gallery to call $_REQUEST['id2'] directly? Or do you want index.php to set up a special variable for it?
|
To see this in action, go see the portfolio page via the link on the navbar of my site. It's just a daisy chain of includes. Index.php--->p_gallery.php--->gal.php
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:
Looks good.
Say index.php is located in www/
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
|
index.php is in the root (we'll call it www/ for now)
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:
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.
|
Exactly what I was just saying.
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:
Actually, you just got me back
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:
...
In to:
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'>";
}
Essentially, I just added elseif( file_exists( $id."/".$id.".php" )
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
...
In to:
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'>";
}
I added a "$base = " statement, and added $base to the 2 image searching and loading lines.
(if the images in www/brewery are called 1.jpg, 2.jpg etc you can leave the code as-is).
|
Okay.
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:
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
|
We are definatly getting somwhere.
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?