I need to make something that involves having a template and creating a page on the fly rather than having to save three million different pages. I searched around for a tutorial and, like we were discussing the other day, just try wanting to figure out something basic around nasty nerds, just fucking try. Among the other things, I stumbled upon a discussion where someone was asking how to do it and everyone piles on them all, "do [completely different thing]", "use [CMS] instead", and even "the fact that you're asking this question means you're not ready". I fucking swear. And now here I am, no more learned than before, but full of murderous rage. Thanks.
Story time aside, what I need to do in more detail is: I need to make a site with a very simple gallery system where you click on an image and you get to a page with the picture and a little description. Since this would be something like 300 pictures, it's simply unfeasible to have it be actual separate pages. Instead, I'd want it to be a single file that pulls the template for each picture, adds the picture and description that's needed, and basically creates the whole page with its own URL (which then can be rewritten if I want, but I think that the standard gallery.php?pic=25 would be pretty okay in this case).
I know I've done something similar many years ago but I forget how it was, and I'd want input from someone who's done that more recently and in a more tried and tested way.
Thank you.
Dynamic pages in PHP
-
- Administrator
- Posts: 2535
- Joined: Thu Jun 21, 2012 5:49 pm
- Contact:
-
- Events Staffer
- Posts: 3072
- Joined: Thu Aug 07, 2014 3:15 pm
- Location: North Carolina, USA
- Contact:
Re: Dynamic pages in PHP
Not sure if any of these scripts/tutorials will do all of what you're looking for, but perhaps looking at their code might give you some clues:
PHP "Generate Photo Gallery" Tutorial (includes use of a JavaScript MooTools thingy)
Single File PHP Gallery - this script looks like exactly what you're looking for
Quick Gallery - also this one
UberGallery
MiniGal
Hoping this helps, Dubs--and I hear ya on the "asking for webdev help and getting absolute shit for answers" rage. (Doncha wish you could be a Sith for a few minutes so you could Force Choke those idiots? LOLOL)
PHP "Generate Photo Gallery" Tutorial (includes use of a JavaScript MooTools thingy)
Single File PHP Gallery - this script looks like exactly what you're looking for
Quick Gallery - also this one
UberGallery
MiniGal
Hoping this helps, Dubs--and I hear ya on the "asking for webdev help and getting absolute shit for answers" rage. (Doncha wish you could be a Sith for a few minutes so you could Force Choke those idiots? LOLOL)
-
- Administrator
- Posts: 2535
- Joined: Thu Jun 21, 2012 5:49 pm
- Contact:
Re: Dynamic pages in PHP
Thank you, but none of those help because the problem is - it needs to be on a separate page, not with those lightbox thingies! I've used those before and yeah, they're really easy to set up and all...but they're not what I need in this particular case, which is why I'm having the problem of having each picture be on a separate page. It cannot be a lightbox gallery for a series of long and tedious reasons - just take this at face value, hehe.
Re: Dynamic pages in PHP
Reminds me of when I was trying to figure out why a script wouldn't work and was told that there was a mistake, rather than what it was. I take it as people who are pretending to know more than they actually do.
Anyway, I'm pretty sure php can do this, you could have a php page that's the template for the separate page, then use variables to tell it which picture and description to use. So you'd have a page with the thumbnails and that's the template, just two pages. Or you can do 3, thumbnails, template and descriptions. You can have all of the descriptions in one place, but only the one with the matching picture variable will display.
As for the variable, it can be automatically generated via scan dir. The most time consuming part would be to write the description next to each variable, though they would be on a single php and the variable list would be automatically generated based on the picture filename. Just copy+paste the list and add the descriptions to it.
It would be similar to what I use here all of those pages are just one page. The php looks at the directory (which must only contain pictures and no other files) then generates the same code for each picture. I have a tutorial here.
That particular script opens in a new window (_blank) but this other version I used here in the fanart section uses an actual page with it's own url. It's just 2 pages (for the pictures), the one with the links and the page where each pic is displayed. If you look at the url, you'll see the variable. What you're describing sounds like a combination of the two plus description, all processed server side. Would that work?
Anyway, I'm pretty sure php can do this, you could have a php page that's the template for the separate page, then use variables to tell it which picture and description to use. So you'd have a page with the thumbnails and that's the template, just two pages. Or you can do 3, thumbnails, template and descriptions. You can have all of the descriptions in one place, but only the one with the matching picture variable will display.
As for the variable, it can be automatically generated via scan dir. The most time consuming part would be to write the description next to each variable, though they would be on a single php and the variable list would be automatically generated based on the picture filename. Just copy+paste the list and add the descriptions to it.
It would be similar to what I use here all of those pages are just one page. The php looks at the directory (which must only contain pictures and no other files) then generates the same code for each picture. I have a tutorial here.
That particular script opens in a new window (_blank) but this other version I used here in the fanart section uses an actual page with it's own url. It's just 2 pages (for the pictures), the one with the links and the page where each pic is displayed. If you look at the url, you'll see the variable. What you're describing sounds like a combination of the two plus description, all processed server side. Would that work?
-
- Events Staffer
- Posts: 3072
- Joined: Thu Aug 07, 2014 3:15 pm
- Location: North Carolina, USA
- Contact:
Re: Dynamic pages in PHP
@Dubs: My apologies, I am no code wizard--I can barely read PHP and Javascript as it is, despite years of trying.
-
- Administrator
- Posts: 2535
- Joined: Thu Jun 21, 2012 5:49 pm
- Contact:
Re: Dynamic pages in PHP
Robin: No don't worry! It's just that that particular thing was specifically what I couldn't do, even though it sounds counterintuitive XD
Mikari: Oooh! Yes! I think that's precisely what I need! I'll have to mess with it a bit to see if I got it but I'm almost sure that this is it! Thank you very much :)
And
Mikari: Oooh! Yes! I think that's precisely what I need! I'll have to mess with it a bit to see if I got it but I'm almost sure that this is it! Thank you very much :)
And
Yeah, I think you nailed it there. >8(Mikari wrote:I take it as people who are pretending to know more than they actually do.
Re: Dynamic pages in PHP
Are you thinking of something done in AJAX? I wanted to do something similar recently where I didn't need to copy and paste my template includes on each page and wanted to see if I could just make an ajax call to include the content but I am not that familiar with it. :(
I am also curious to know how Mikari's script works out...
And never look for answer on stackoverflow OMG I SWEAR. I browse for work sometimes and it kills me how Holier-Than-Thou these people are. It's just a simple question, answer if it you can and leave the snark at the door! /guh
I am also curious to know how Mikari's script works out...
And never look for answer on stackoverflow OMG I SWEAR. I browse for work sometimes and it kills me how Holier-Than-Thou these people are. It's just a simple question, answer if it you can and leave the snark at the door! /guh
-
- Administrator
- Posts: 2535
- Joined: Thu Jun 21, 2012 5:49 pm
- Contact:
Re: Dynamic pages in PHP
I actually did use Mikari's idea, it's just that the site in question isn't ready yet so I don't have anything to show. It also had to be expanded a lot to the purposes of this site so right now it's all a bit confusing. When it's ready I will show you :D
I try to avoid! But sometimes I just want to know and I can't help but look and then I regret it 8(
I try to avoid! But sometimes I just want to know and I can't help but look and then I regret it 8(
-
- Events Staffer
- Posts: 3072
- Joined: Thu Aug 07, 2014 3:15 pm
- Location: North Carolina, USA
- Contact:
Re: Dynamic pages in PHP
Offtopic: Thirded on the StackOverflow argh. While looking through my domain linkbacks a few months ago, there was one from StackOverflow, referencing one of my explanation images from a webdesign post I did. The ensuing commentary pretty much ripped me a new one as a "hopeless amateur," "oh, it's a GIRL writing/making this of course it sucks," and all sorts of other elitist crap.
Much butthole. Many nose in the air. Such need to strangle. Wowww.
Ontopic: Glad to hear the script is working! Looking forward to the awesomeness! :D
Much butthole. Many nose in the air. Such need to strangle. Wowww.
Ontopic: Glad to hear the script is working! Looking forward to the awesomeness! :D