View Single Post
Old 04-29-2005, 10:32 PM   #16 (permalink)
arch13
Loves my girl in thongs
 
arch13's Avatar
 
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:
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?
__________________
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
arch13 is offline  
 

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360