How to make a website template? Do not prescribe every page as a manual. Just make a skeleton on divas, or do you need something else?
3 answers
Well, as a rule, header, footer, i.e. header and basement, you make them up and then you just connect it with the help of include () to all files.
- Thank. I'll try. - new_russian_man
- oneincloud? :) so someone else is doing? - Kenpachi
- Engage, even as! Take for example 1C Bitrix - DemoS
index.tpl:
<html> <head> <title> {TITLE} </title> </head> <body> {CONTENT} </body> </html>
index.php:
<? $title = 'Ололо'; $content = 'Тролололололо'; $html = str_replace( array('{TITLE}','{CONTENT}'), array($title,$content), file_get_contents("./index.tpl")); echo $html; ?>
- those. No replacement function is needed? - new_russian_man
- onestr_replace (...) - what's yours? Simply from the base script output the information to the page in the variable $ content, then the script inserts this information to where you have in the template {CONTENT}. Ie, depending on the variable $ contetn, the content of your site will change, and only 1 constant tpl file or whatever you want to give him permission. - Kenpachi
In due time I did a primitive template maker. He looked like that. The layout designer inserted the meta tags (for example, where the menu is, he put the ### menu ###, where the news block is ### news ###, and so on). It is clear that then it can be processed by the usual substitution, but it is a long time. Therefore, a simple script was written on perl, which took the template and replaced the usual replacement with ### menu ### with <?php include "menu.php" ?>
And so on (at first it was a regular replacement, then a regular schedule, which is File checked, and left tags cut off). Later even the parameters appeared. It is clear that not everything was through include. For example, the tag ### copyright ### replaced with just the desired text. As a result, I was just working on scripts, a simple form for filling templates was made for the designer, which immediately generated the php script and checked simple errors (just html lint from cpan).