Hello man or woman.
A google search for this could be something like the one below.
You can add or exclude some words to refine your search.
My own idea is:
Use database tables to store:
Block templates, re-usable page bits
Stuff, data, to put in those bits
Download or write Your Custom Template Engine that can assign + parse data into blocks
------
There are many such php template engine. I prefer the more barebone, simple, lightweight engines. I avoid Smarty and those with special syntax.
Keep with those using plain PHP Syntax for Class or Function.
Make use of http://docs.php.net/str_replace
it is the fastest way to assign and replace your custom template tags in such template blocks.
<?php
$page = '';
// tags are like: {{copyright}} {{video}} {{googlead1}}
$pageblock1 = $template1;
// parse data into each template block
foreach( $tag_data_array1 AS $find=>$replace ){
$pageblock1 = str_replace( '{{'.$find.'}}', $replace, $pageblock1);
}
$page = $page . $pageblock1;
$pageblock2 = $template2;
// parse data into each template block
foreach( $tag_data_array2 AS $find=>$replace ){
$pageblock2 = str_replace( '{{'.$find.'}}', $replace, $pageblock2);
}
$page = $page . $pageblock2;
// and so on for all blocks templates you want to inlcude in page
// finally DISPLAY resulting html code
echo $page;
?>
I use often only 3 blocks per page:
- header.tpl
- contents.tpl
- footer.tpl
... but of course CONTENTS can be any number of blocks:
- header.tpl
- topmenu.tpl
- leftmenu.tpl
- mainleft.tpl
- mainmiddle.tpl
- mainright.tpl
- bottom_advertise.tpl
- footer_links.tpl
- footer_copyright.tpl
- footer_ads.tpl
- footer.tpl
And you can let some BLOCK use several SUB-blocks.
Like footer.tpl can include LINKS COPYRIGHT & ADS and whatever.
Here is my google search:
php template block page display parse assign database tutorial OR article
.... but adjust this search by remove/add words, to make it 'perfect'
I am sure you will find some Article / Tutorial or Small Template Engine to download.
Basically you design your Block Templates.
You Pull Page Data from database tables.
Assign Data to Templates.
Finally Display the result.
I may post my own small & fast
Lightning Template Engine Class in Code Critics forum.
If any body wish & ask me to ....
Good Luck 🙂
halojoy