Menu template with links

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

There is 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 menus – following links. So that the template remains the same, but the content changes? + It would be nice to add dynamics, those the ability to add menu items and therefore new content. How many int did not dig – it is not clearly written everywhere.


Answer 1, authority 100%

<?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;
?>

Answer 2

It makes sense to use an iframe. Theory:

General view: 2 panels joined at the front.

  1. The index.php page contains a menu that needs to be placed as a block on the left. On the right we place an iframe with noborder and so on. optional
  2. We set the receiving parameter (for example, file), i.e. switch($_GET['file']){case‘log’:$file=’log.php’ break;}
  3. Set iframe to src="<?php echo("$file") ?>"
  4. For starters, rejoice. Using jquery or ingenuity, you can designate a marked menu item. etc. It all depends on the ingenuity and skills and preferences. This is how I made the admin panel for my cms. If you have any questions – write to the soap.