chmpdog Posted November 28, 2008 Share Posted November 28, 2008 Hey, I created a template system a while back, but I didn't take into account that I might have wanted content titles. Basically, the entire site is linked to the index.php file which includes needed files. Say I have a login page, and now I can make the content-title say login (see the second code box), but I cant make it say login failed. Is there a way to set a variable in the included file, then echo it in savor.php (see below) as the content title? here take a look: include ('include/savor.php'); // computes the pages & title based on $_get info session_start(); // Include the template include ('template/index.php'); ob_end_flush(); Now, savor.php computes the page info using a switch: function page_title() { if (isset($_GET['task'])) { switch($_GET['task']) { case 'page': include('thepage.php'); break; default: echo 'Page Not Found'; break; }}} Now that function is then transported to the template file, which basically does the function. I hope I gave enough info, thanks for the help, Charlie PS: I also tried using $_SESSION but it echoed the page a page late ( needed to refresh to take affect) meaning it wasnt set until after the template was run Quote Link to comment https://forums.phpfreaks.com/topic/134583-my-template-system-including-content-title/ Share on other sites More sharing options...
chmpdog Posted November 28, 2008 Author Share Posted November 28, 2008 Is there no answeres? Quote Link to comment https://forums.phpfreaks.com/topic/134583-my-template-system-including-content-title/#findComment-700775 Share on other sites More sharing options...
swizzer Posted November 28, 2008 Share Posted November 28, 2008 I don't understand specifically why you can't output information between title tags, but it seems as if you're mixing your logic and template code, resulting in this only working on the second trial. On a side note, there are many template systems created that support everything you could possibly imagine, like smarty, are they not good enough for you ? Quote Link to comment https://forums.phpfreaks.com/topic/134583-my-template-system-including-content-title/#findComment-700793 Share on other sites More sharing options...
laffin Posted November 28, 2008 Share Posted November 28, 2008 u have to add more logic to yer template system, especially on forms. I was working on a template system awhile back, its pretty good. modules had different pre / main functions. to decide whether to process forms / show errors / display forms / load different page according to form data First ya have to figure out a way to give which step ya are on. such as http://www.site.com/index.php?p=register wud check for any POST information No Post Info ---> jump to display page (form) else process post info is post info ok? Yes, Change the Page load to main/index (or redirect) No, save error codes for form display Display page (form) Quote Link to comment https://forums.phpfreaks.com/topic/134583-my-template-system-including-content-title/#findComment-700900 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.