Convert to link

How to convert $tpl->sub_load_template('sub.tpl'));to a link like index.php?do=sub

Well, look here: http://makar3000.s3.webhost1.ru/panel2/index.php?do=login

The main.tpland the new template appear. In index.php

include ("templates.class.php");
$do = $_GET['do'];
if ($do == 'login') {
    include './templates/login.tpl';
}
$tpl   = new Template; // 
$tpl->dir = 'templates/'; //    
$tpl->load_template('main.tpl'); // 
$tpl->compile('main'); // 
echo $tpl->result['main']; //  
$tpl->global_clear(); //      

But I need it to show only login.tplwhen going to login.tpl.


Answer 1, authority 100%

There are nails, a hammer and boards, how to build something like this … ?

Look towards the $_GET global variable. In short, you can say to get something specific by index.php?do=sub

In index.php

if (!empty($_GET['do']) && $_GET['do'] == "sub") {
//    ,     
} else {
}

Answer 2, authority 100%

um…. I messed up a little in DLE.. but in my opinion, even a noob understands how to do it here:

include ("templates.class.php");
$tpl   = new Template; // 
$tpl->dir = 'templates/'; //    
switch($_GET['do'])
{
     case 'login':
         $tpl->load_template('login.tpl'); // 
    break;
    default:
          $tpl->load_template('main.tpl'); // 
}
$tpl->compile('main'); // 
echo $tpl->result['main']; //  
$tpl->global_clear(); //      

Answer 3, authority 100%

Until you understand the $_GET superglobal array, don’t bother.
Example :

<?php
$var1   =   $_GET['keyname'];
#
if ($var1 == 'home') {
    echo '  ';
} elseif ($var1 == 'about') {
    echo '   about';
}
?>

Look closely at the code, and imagine that $_GET[]is an array, the keyname in the $_GETarray is the key of the array, so that this key contains data, we should assign them to him, but in a slightly different way, like this (open in a browser on the site): __.php?keyname=123.
And with such a record, the variable $var1in our script will be equal to “123”.
Key/value pairs in URLs are listed using & (and), example:
zxzx.php?kluch1=znachenie1&key2=value123123
From the entry above, we learn that $_GET['kluch1']is equal to znachenie1 and $_GET['key2']is equal to value123123.