We have a main page template. It is here for clarity (index.tpl)

There is an index.php

<?php header('Content-type: text/html; charset=utf-8'); $f1="index.tpl"; if (!file_exists($f1)) { header('Content-type: text/html; charset=utf-8'); echo "<center> <br><br> <h1>нет шаблона!</h1> </center>"; exit; } $f = fopen($f1,"r"); $site = fread($f, filesize ($f1)); fclose ($f); require_once "news.php"; $site=str_replace('{news}',$news,$site); echo "{$site}"; exit; ?> 

How to organize the menu - go to the links. So that the template remains the same, but the contents change? + It would be nice to add speakers, the ability to add menu items and therefore new content. How many int did not dig - it is incomprehensibly written everywhere.

    2 answers 2

     <?php header('Content-type: text/html; charset=utf-8'); $f1="index.tpl"; if (!file_exists($f1)) { header('Content-type: text/html; charset=utf-8'); echo "<center> <br><br> <h1>нет шаблона!</h1> </center>"; exit; } $menu = '<a href="?mode=ololo">OLOLOLO</a><br> <a href="?mode=trololo">TROLOLOLO</a>'; if($_GET['mode']=='ololo'){ $content = "LOOOOOOOOOOOOOOOOOOOOOOOOOOL"; } elseif($_GET['mode']=='trololo'){ $content = "BLA BLA BLA BLA BLA"; } else{ require_once "news.php"; $content=$news; } $site=str_replace(array('{content}','{menu}'), array($content,$menu), file_get_contents("index.tpl")); echo $site; exit; ?> 
    • <a href="?mode=trololo"> TROLOLOLO </a> 'for example, I can't understand what the? mode = why is that? - new_russian_man
    • mode - $ _GET variable, which we process and depending on its content, we display this or that content - stck
    • new_russian_man, because before creating a site, make sure to read at least trivial php documentation (php.su/net to help you) - Kenpachi

    It is advisable to use an iframe. Theor:

    General view: 2 panels docked on the front.

    1. The index.php page contains a menu that must be placed as a block on the left. On the right we place the iframe with noborder parameters, etc. optional
    2. We set the receiving parameter (for example file) switch($_GET['file']){case 'log': $ file = 'log.php' break;}
    3. Set iframe src="<?php echo("$file") ?>"
    4. For a start, we rejoice. Using jquery or ingenuity, you can indicate a marked menu item. etc. It all depends on intelligence and skills and preferences. So I did admin panel for my cms. Any questions - write to the soap.
    • Use iframe O_O to change the content O_O What kind of nonsense, sir? Please do not confuse people. - Kenpachi
    • why not? everything comes with experience, it is better to start with a simpler one, no? - stck
    • I think not, comparing to drawing in paintte instead of photoshop. If the site is written in php, it is better to use it (php). Not that your option does not have the right to exist, then simply it is better to use a separate html file for each section. - Kenpachi