Hello, I was wondering if any of you could give me some guides on how to use one "main" template to update all pages on my site (instead of updating each page). For example, if I need to make some changes on left/right/top/bottom side, I only need to make the change on my "main" template and all of the pages will automatically changed. I heard it could be done using php and modifying .htaccess. I don't really understand it. Could any of you please give me some guides? Thank you in advance. I'd really appreciate it Jess
I don't think you'll need .htaccess to accomplish that. Here's my solution: create a file ('template.php') like the following (in principle, not in contents ): <html> <head> <title><?=$_title?></title> </head> <body> <h1>Jess.Com</h1> <p>Here you can put various content or HTML code that will be the same from the whole site ...</p> <?=$_content?> </body> </html> PHP: Now create a file that will use the above template: <? $_title = "My Test Page"; $_content = "Let's try this out ..."; include('template.php'); ?> PHP: Voila! Again, this is the principle to be used, not the solution. All variables and the template can contain whatever HTML code you want. For the template.php file, most likely, you should continue writing it on the code produced by the graphical layout cut.
I think what you are asking is how is that done. All the pages of the site are created from 3-6 other pages. Something along the lines of header, menubar, main body, footer and may have a couple of more. In this example header, menubar and footer would be the same on every page of the site. Main body would be unique for each page or pulled from a database. This and what Evoleto wrote above are two different ways to achieve almost the same visual result. His way might be better for SEO.
Also for more complex solutions there are template engines with wide functionality. I use Smarty (smarty.php.net) and think, it's very good and easy solution to use, also with some customizations it could be used in different projects
Thank you, Evoleto! Will give it a try Thank you Colbyt! I'd like to learn that. May I know how to do that? Is it way complicated for a beginner? Thank you intoex. I'll check it out I really appreciate your help, guys!
I have not learned enough CSS yet to do it that way. So I am still using tables. This is a link to a sample page I put up for someone else. You can see how the 5 different pages are combined into the one page named sample.php. The sample is a few months old so there are a couple of broken links on the page. You do it by using the include function of php: <?php include "menu.inc"; ?> Code (markup): That line of code includes the file named menu.inc. Menu.inc is nothing more than an HTML file renamed with the .inc extension. It takes that one line of code with the different file names to include the 5 different pages. You just put the correct line of code into a table or, div if using CSS, to make the page appear there. The beauty of the system is that if you have 200 pages in your site and need to change the menu you only have to change one file to change them all. Play with it on some sample files.