nvee Posted September 17, 2008 Share Posted September 17, 2008 Hey Guys To start of with, I have been into web designing for quite a couple of years, and do understand the basic fundementals of PHP, but I have to be honest that I am far from experienced and should you paste code here I will most likely as the same question again But hopefully I can get some answers which can help myself and our business improve our services to our customers. We're based in South Africa and work for a government fund which gives websites to businesses for free. You can understand that we work under pressure to get work done and our designers are more graphic designers than web developers. So the obvious would be to work with a simple php template script which allows us to design a template, and then practically include our content pages. Now I have worked with frames, Iframes, CSS and tables and we currently design our websites with tables adding styling to it via style sheets, and then in our content area we have a nifty little script which we include which acts like a controller. I have assigned the script at the bottom. Now I assume alot of people use this script seeing that I notice it gives us that index.php?id=home as an example and I see similiar code on other pages. Now this works well except for when we want to include a feedback form or our latest problem a plogger photo gallery. What this script does not allow us to do is to almost include other php scripts. If we want to for example add a feedback form it works but the next window does not display correctly. We usually get a headers already sent or with plogger it gives a not a situable wrapper error. The php template script allows us to specify which pages to load but seeing that we do not know what pages a feedback form, guestbook or photo gallery would want to load, how will we specify or work around this. Is there another way to get a nice template system and still be able to include other php scripts without getting a headers already sent or not a situable wrapper. Here is the code <?php if (isset($_GET['id'])) { $linkchoice=$_GET['id']; } else { $linkchoice=''; } switch($linkchoice) { //Main Navigation Buttons case 'home' : include ("includes/home.php"); break; case 'about' : include ("includes/about.php"); break; Link to comment https://forums.phpfreaks.com/topic/124626-php-template-system-not-working-that-well/ Share on other sites More sharing options...
DarkWater Posted September 17, 2008 Share Posted September 17, 2008 That's not *really* a template system. If you'd consider it one, it is a very...rudimentary one. A real templating system is Smarty or another of the like (you can google Smarty). Anyway, I'm not quite sure what your problem is...can you explain it better? Link to comment https://forums.phpfreaks.com/topic/124626-php-template-system-not-working-that-well/#findComment-643653 Share on other sites More sharing options...
nvee Posted September 17, 2008 Author Share Posted September 17, 2008 Hey Darkwater Yes after reading it i noticed my approach was a bit off. I added you on msn (sorry i know its without your approval) but this thing is driving me mad! In short, we dont mind doing the work like we're doing it at the moment. And i understand its not really a template engine, but we dont really want a 100% template engine based on the time consumption each product will take and we want to atleast have the website look "unique". All of our sites mostly contains static text so when we do update a site we do it manually. Our problem is that with the script which i pasted above, you have to specify each and every page on your site e.g. if we work on a 5 section site, we have to assign in our paging.php file (the script above) a case include for each file. You will notice i added to above (home and about). Now this works perfectly if you know exactly how many pages you will have. Obviously our links then <a href="?id=home">home</a>. I am sure your fimiliar with the concept. Now the problem comes in when we want to display for example a photo gallery or even a simple feedback form. The form shows, but the action="feedback.php" which contains header information usually gives us a headers already sent error. We managed to bypass that problem by displaying the feedback results in a new window without the template with a link back to the website. With a script like plogger which gives you a photo gallery on your site, we cannot get it to work correctly based on the fact that we do not know what links plogger will try to make. So when someone clicks on a gallery it wont open because it was not initially assigned in the paging.php file. We have no control over what links external software will try to make so the paging.php script does not work that well. So far we have only got headers already sent errors or with plogger "not situable wrapper". In short what other approaches can we take to have the same control over our sites, still design it as a template and then just including the content into a content area without running into issues like this. I hope it makes more sense. Link to comment https://forums.phpfreaks.com/topic/124626-php-template-system-not-working-that-well/#findComment-643662 Share on other sites More sharing options...
nvee Posted September 17, 2008 Author Share Posted September 17, 2008 Lets try again for a last time I understand its not a template system, but for the sake of argument lets call it one Lets rephrase saying its a content loader The content loader is a single file called paging.php - The file gets included in where we want the content to appear. So in the table cell where the content will appear, we include it <?php include(paging.php); ?> The actual paging.php file contains all the content pages entries. So if we have 6 actual pages we make 6 entries (as shown above) for the individual pages. When we click on a link it loads the appropriate file, and this is where the problem comes in. It will check if we made a entry for the link e.g. about. If the about us has not been entered into the script, it will load the default page. So in short it only loads entries listed in the document. Our problem is that with for e.g. plogger it has a variety of links, obviously going to the individual pages, it is impossible for us to include all of the possible links as entries in the paging.php file, so we're actually looking for an alternative to design a template, insert all of the images and styling, and then having content pages seperate so that when the layout change we dont have to change all of the pages, but just the single index.php file. But still be able to include php scripts which directs to other confirm or fail pages ect. Hope it is better explained now Link to comment https://forums.phpfreaks.com/topic/124626-php-template-system-not-working-that-well/#findComment-643668 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.