c
This commit is contained in:
@@ -48,12 +48,13 @@ class AppAdmin
|
||||
str_replace("-", "_", $this->current_route_info["view"]).".php"
|
||||
]) ;
|
||||
|
||||
if(!file_exists($module_file)) {
|
||||
if(file_exists($module_file)) {
|
||||
// print_r($this->current_route_info);
|
||||
die('Page '. $module_file .' not found!');
|
||||
}
|
||||
|
||||
// die('Page '. $module_file .' not found!');
|
||||
$data = include_once $module_file;
|
||||
}else{
|
||||
$data = ['file data '. $module_file .' not found!'];
|
||||
}
|
||||
|
||||
$global_data = [
|
||||
"module" => $this->current_route_info['module'],
|
||||
@@ -71,11 +72,16 @@ class AppAdmin
|
||||
|
||||
protected function renderModule() {
|
||||
|
||||
$template_file_path = $this->tpl_path ."/". $this->current_route_info['module']."/".$this->current_route_info['view'].".html";
|
||||
$template_file_path = $this->tpl_path ."/". $this->current_route_info['module'];
|
||||
$template_file_name = $this->current_route_info['view'].".html";
|
||||
$template_file_full_path = $template_file_path."/".$template_file_name;
|
||||
|
||||
//check exist
|
||||
if(!@file_exists( $template_file_path)) {
|
||||
die("Not found : ". $template_file_path);
|
||||
if(!@file_exists( $template_file_full_path)) {
|
||||
// attempt to auto create first
|
||||
if(!$this->autoCreateTplFile( $template_file_path, $template_file_name )) {
|
||||
die("Please manually create template file at: ". $template_file_full_path);
|
||||
}
|
||||
}
|
||||
|
||||
$theme_file_path = $this->tpl_path ."/theme.html";
|
||||
@@ -84,7 +90,7 @@ class AppAdmin
|
||||
}
|
||||
|
||||
$theme_content = @file_get_contents( $theme_file_path );
|
||||
$module_content = @file_get_contents( $template_file_path );
|
||||
$module_content = @file_get_contents( $template_file_full_path );
|
||||
|
||||
$page_content_to_parse = preg_replace([
|
||||
"/{{(\s+)?page_content(\s+)?}}/"
|
||||
@@ -99,6 +105,27 @@ class AppAdmin
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
protected function autoCreateTplFile($file_path, $file_name) : bool {
|
||||
// create dir if not exist
|
||||
if(!file_exists($file_path)) {
|
||||
if(!mkdir($file_path, 0755, true)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if(!file_exists($file_path)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//create file
|
||||
$file_full_path = $file_path . "/". $file_name;
|
||||
@file_put_contents($file_full_path, $file_full_path);
|
||||
|
||||
return file_exists($file_full_path);
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* 2 ways to render a html template
|
||||
* 1. Use $html_to_parse, which requires no dependencies
|
||||
|
||||
0
template/customer/comment.html
Normal file
0
template/customer/comment.html
Normal file
0
template/customer/customer-contact.html
Normal file
0
template/customer/customer-contact.html
Normal file
0
template/customer/home.html
Normal file
0
template/customer/home.html
Normal file
0
template/customer/review.html
Normal file
0
template/customer/review.html
Normal file
0
template/template/home.html
Normal file
0
template/template/home.html
Normal file
@@ -31,7 +31,7 @@
|
||||
|
||||
<!-- Menu full -->
|
||||
<div class="admin-menu-container box-menu sticky top-0 bottom-0 h-[100vh] hidden" id="js-menu-big">
|
||||
<a href="javascript:void(0)" class="icon-close" id="js-hide-menu">
|
||||
<a href="javascript:void(0)" class="icon-close" title="Thu gọn menu" id="js-hide-menu">
|
||||
<i class="fa-solid fa-outdent"></i>
|
||||
</a>
|
||||
|
||||
@@ -116,7 +116,7 @@
|
||||
<a href="/" class="">
|
||||
<img src="../assets/images/logo_small.png" alt="">
|
||||
</a>
|
||||
<a href="javascript:void(0)" class="icon-close" id="js-show-menu">
|
||||
<a href="javascript:void(0)" title="Mở menu" class="icon-close" id="js-show-menu">
|
||||
<i class="fa-solid fa-indent"></i>
|
||||
</a>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user