I just started programming PHP, I know how to enable PHP, but in this case I ran into difficulties. I have a LAMP server, in the root folder I set my own structure, as shown below (folders in capital letters).
index.php
page.php
INCLUDES
- classes.php
- skins.php
- flow_init.php
- flow_head.php
- flow_body.php
SOURCES
- page1.php
- page2.php
...
THEME_HTML
- wrapper.html
VIEWS
- page1.html
- page2.html
...
wrapper.html created in index.php
<?php
$skin = new skin('wrapper');
echo $skin->make();
This is my skins.phpfile.
<?php
class skin {
var $filename;
public function __construct($filename) {
$this->filename = $filename;
}
public function mk($filename) {
$this->filename = $filename;
return $this->make();
}
public function make() {
global $CONF;
$file = sprintf('./'.$CONF['theme_path'].'/'.$CONF['theme_name'].'/html/%s.html', $this->filename);
$fh_skin = fopen($file, 'r');
$skin = @fread($fh_skin, filesize($file));
fclose($fh_skin);
return $this->parse($skin);
}
private function parse($skin) {
global $TMPL, $LNG;
$skin = preg_replace_callback('/{\$lng->(.+?)}/i', create_function('$matches', 'global $LNG; return $LNG[$matches[1]];'), $skin);
$skin = preg_replace_callback('/{\$([a-zA-Z0-9_]+)}/', create_function('$matches', 'global $TMPL; return (isset($TMPL[$matches[1]])?$TMPL[$matches[1]]:"");'), $skin);
return $skin;
}
}
?>
Each page VIEWSis created inside SOURCESand page.phpechoed.
Script for integration
Everything works fine, but now I need to integrate this script between the wrapper (where there is a title tag) and one view (where the content is)
<?php
session_start();
require_once('admin/plugins/flow-flow/ff-injector.php');
$injector = new FFInjector();
?>
<!DOCTYPE html>
<html lang="en-US">
<head><?php echo $injector->head(true,true); ?>
</head>
<body>
<table width="100%">
<tr>
<td style="width: 300px;vertical-align: top">
<?php
$stream_id = isset($_REQUEST['stream']) ? $_REQUEST['stream'] : 1;
$injector->stream($stream_id);
?>
</td>
</tr>
</table>
</body>
</html>
For this purpose, I tried to create several templates:
<?PHP
$TMPL['flow_init'] = include './includes/flow_init.php';
$TMPL['flow_head'] = include './includes/flow_head.php';
<?PHP
$TMPL['flow_body'] = include './includes/flow_body.php';
Where are my included files installed below
<?PHP
session_start();
require_once('admin/plugins/flow-flow/ff-injector.php');
$injector = new FFInjector();
?>
<?PHP
echo $injector->head(true,true);
?>
<?PHP
$stream_id = isset($_REQUEST['stream']) ? $_REQUEST['stream'] : 1;
$injector->stream($stream_id);
?>
What do I expect to achieve
flow_init flow_head , :
// THEME_HTML/wrapper.html
{$flow_init}
<!DOCTYPE html>
<html lang="en">
<head>
{$flow_head}
</head>
<body>
<div id="content" class="wrapper">
{$content}
</div>
</body>
</html>
flow_body
<div class="row-body{$content_class}">
<div class="body-content">
<div class="nine columns" id="main-content">
{$flow_body}
</div>
<div class="three columns">
{$sidebar}
</div>
</div>
</div>
, , 3 index.php, , , .
PHP script ?