|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Template loading dynamic pages
Hi,
I wonder if anyone can help. What I am trying to do is use my basic template system to call dynamic pages into the body of the template. So template.php has the basic header/footer includes, and in the body of template.php, I have another include calling body.php. On that page, I want to include some html (an image with some text) which will be displayed between the header & footer. Now I know how to do this with one page, but I want it to be dynamic. See, I am using a java slideshow on another page (which needs http links) that has thumbnails that when you click on one, it will open the template.php with the default header/footer, and that thumbnail (enlarged) with it's description in the body of template.php. I assume the url to call these from the external slideshow would be (i.e) www.website.com/template/template.php?image#1 or something along those lines. I can't for the life of me figure out what I need to include to enable this to work. Can anyone help me out please? Thanks in advance Jonathen |
|
#2
|
|||
|
|||
|
RE: Template loading dynamic pages
I'm assuming the easiest way to get what you want accomplished is to use URL variables as you mentioned. In the template.php you should be able to access those URL variables using the HTTP_GET_VARS array for example.
When clicking on the image in your other page it would call your template.php http://yourwebsite.com/template.php?imagenum=1 echo $HTTP_GET_VARS["imagenum"]; ---you should get 1 Then you can pull up the correct body template if you have multiple body templates or pass along those variables to a single body template and make that do all the work of choosing the correct image, html layout, etc.. Hope that helps, -CBronson |
|
#3
|
|||
|
|||
|
RE: Template loading dynamic pages
Thanks, that's a great help
|
|
#4
|
|||
|
|||
|
RE: Template loading dynamic pages
I do something like this:
if (!empty($page)) { $pageurl = $page . ".php"; if (file_exists($pageurl)) { include($pageurl); } } else { //do this stuff } then you call it like so: yourserver.com/index.php?page=contact where contact.php would be the included file... |
|
#5
|
|||
|
|||
|
RE: Template loading dynamic pages
Thanks for that sethadam1 - I figured a way of calling images, but still need to call .txt files dynamically, so when I saw what you posted, I tried that, but it doesn't display the content of the .txt file when calling template.php?page=1.txt
The code I have used is as you said: if (!empty($page)) { $pageurl = $page . ".txt"; if (file_exists($pageurl)) { include($pageurl); } } else { //do this stuff } Am I missing something? |
|
#6
|
|||
|
|||
|
RE: Template loading dynamic pages
this may be a typo but, if you pass '1.txt' then $pageurl will end up being be '1.txt.txt'
and make sure you still have register_globals set to 'on'. otherwise reference $page as $_GET['page'] |
|
#7
|
|||
|
|||
|
RE: RE: Template loading dynamic pages
Try the same code, you've used and call it like this: template.php?page=1 Quote:
|
![]() |
| Viewing: Codewalkers Forums > PHP Related > PHP Coding > Template loading dynamic pages |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|