Re: [PHP] template logic problem
By default, PHP can start sending output before it's all been generated. This results in faster results for web site visitors. On the other hand, it's not compatible with deciding late in the game that you want a few extra headers. If you want to do this sort of thing, read about output buffering in the manual; it's pretty straightforward. miguel On Tue, 14 May 2002, list peters wrote: I was hoping i could do something like you suggested. Cold Fusion has a tag called cfhtmlhead that will include anything within the head tags. You can call this function even on the last line of your php template. I used this a lot. Has anyone written a function like this? I tried searching but couldnt find anything. thanks chad What I'd do is change your include()d template to wrap a function around the HTMLBODY stuff. Then you can call it once you have enough information available, and pass in any variable elements like the name of that rotating image. This will make your templating a whole lot more flexible (you can now specify the TITLE on each page, for instance). miguel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] template logic problem
In article 001f01c1fae4$5291f830$0d01a8c0@avex, [EMAIL PROTECTED] says... HI miguel, thanks for your answer. I was hoping i could do something like you suggested. Cold Fusion has a tag called cfhtmlhead that will include anything within the head tags. You can call this function even on the last line of your php template. I used this a lot. Has anyone written a function like this? I tried searching but couldnt find anything. thanks chad What I'd do is change your include()d template to wrap a function around the HTMLBODY stuff. Then you can call it once you have enough information available, and pass in any variable elements like the name of that rotating image. This will make your templating a whole lot more flexible (you can now specify the TITLE on each page, for instance). miguel Maybe you could incorporate output buffering to achieve your goal? -- David Robley Temporary Kiwi! Quod subigo farinam -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] template logic problem
hi everyone, This is my first project with php after using cold fusion for the last few years! So far I have been pretty happy with php, but I have a problem with my application logic (not a php problem, but hoping for a sexy solution.) I am using a template system and including different content files depending on URL parameters. eg html body navigation ?php include file depending on url? body /html In the include file I have all the code i need. My problem is that for one page in the site I need to display a image in the navigation bar that is referenced from a database. The database query happens in the included file which is below the navigation in the html - This means i cant reference the image file name because the query hasnt happened. So is it possible to specify in the included file that some php proccessing happens before anything else? Or can I use some tricky javascript? Or is there a cool php trick to do something like this? Does anyone have any ideas? thanks chad -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
RE: [PHP] template logic problem
My problem is that for one page in the site I need to display a image in the navigation bar that is referenced from a database. The database query happens in the included file which is below the navigation in the html - This means i cant reference the image file name because the query hasnt happened. I suspect that in the end any tricks you play will be just that - tricks. If you require certain information to properly render a particular part of the page then you should really generate that information before you render that part of the page. Perhaps using a function to extract the image you need as part of your navigation will work. Or can I use some tricky javascript? I don't really know enough javascript to give a full answer but it's you might get away with having some sort of place-holder image (single pixel transparent gif perhaps) set up and then use an event of some sort to change it to the image you really wanted (not sure if an onload() type function would work here or if you'd have to do something else though). Check some javascript resources to look into that - I like www.irt.org myself for that sort of thing. CYA, Dave -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] template logic problem
My problem is that for one page in the site I need to display a image in the navigation bar that is referenced from a database. The database query happens in the included file which is below the navigation in the html - This means i cant reference the image file name because the query hasnt happened. I don't believe this can be done in any simple way. Javascript is certainly not your answer, regardless of if it can do it, it's just not smart to place such a burden (navigation of the site) onto JS, which will inevitably break, or won't be available, or will be off. What you need to do is change your include file to do the following, and include it above the nav bar: - do the query - create the navigation - create a $output var, which you use instead of echo, which renders the stuff you'll use further down the page. eg: ? // do query // build navigation // create output to be used later $output = ; $output .= something something\n; $output .= something else\n; ? !-- other stuff, then finally: -- ?=$output? Justin French -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] template logic problem
On Mon, 13 May 2002, list peters wrote: This is my first project with php after using cold fusion for the last few years! So far I have been pretty happy with php, but I have a problem with my application logic (not a php problem, but hoping for a sexy solution.) I am using a template system and including different content files depending on URL parameters. eg html body navigation ?php include file depending on url? body /html In the include file I have all the code i need. My problem is that for one page in the site I need to display a image in the navigation bar that is referenced from a database. The database query happens in the included file which is below the navigation in the html - This means i cant reference the image file name because the query hasnt happened. What I'd do is change your include()d template to wrap a function around the HTMLBODY stuff. Then you can call it once you have enough information available, and pass in any variable elements like the name of that rotating image. This will make your templating a whole lot more flexible (you can now specify the TITLE on each page, for instance). miguel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] template logic problem
HI miguel, thanks for your answer. I was hoping i could do something like you suggested. Cold Fusion has a tag called cfhtmlhead that will include anything within the head tags. You can call this function even on the last line of your php template. I used this a lot. Has anyone written a function like this? I tried searching but couldnt find anything. thanks chad What I'd do is change your include()d template to wrap a function around the HTMLBODY stuff. Then you can call it once you have enough information available, and pass in any variable elements like the name of that rotating image. This will make your templating a whole lot more flexible (you can now specify the TITLE on each page, for instance). miguel -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php