Site Template (Last OK 17-04-2014) π
This PHP file serves as the master layout for the Logistics front-end. It orchestrates the inclusion of configuration, meta tags, header, navigation, content, footer, and an optional profiler panel. Its modular structure allows swapping templates dynamically based on the current page.
Purpose π―
- Assemble a consistent page structure across the Logistics portal.
- Dynamically load template fragments (
_top,_meta,_content) based on$current_template_name. - Offer built-in profiling for execution time and database query logging.
Dependencies & Includes βοΈ
| File / Constant | Role |
|---|---|
inc/config.php |
Defines core constants (e.g., TEMPLATE_DIR, PROFILER, DB_NAME) |
TEMPLATE_DIR . $current_template_name . "_top.php" |
Template-specific header override (if exists) |
TEMPLATE_DIR . "inc/template_meta.php" |
Common <meta> tags and CSS/JS includes |
inc/panels/meta.php |
Shared meta elements or scripts |
TEMPLATE_DIR . $current_template_name . "_meta.php" |
Template-specific meta override (if exists) |
inc/panels/header.php |
Main site header (logo, login status) |
inc/panels/top_nav.php |
Primary navigation bar |
inc/panels/small_banner.php |
Optional banner (shown unless template excluded) |
TEMPLATE_DIR . $current_template_name . "_content.php" |
Main content area injected per page |
inc/panels/footer.php |
Site footer (copyright, links) |
PROFILER, $GLOBALS['BENCHMARKS'], $GLOBALS['QueryLog'] |
Runtime profiling and DB query logging |
Page Assembly Flow ποΈ
-
Configuration Load
<?php include_once("inc/config.php");Establishes constants and starts timer if profiling is enabled .
-
Template-Specific Top Include
if (file_exists(TEMPLATE_DIR . $current_template_name . "_top.php")) { include_once(TEMPLATE_DIR . $current_template_name . "_top.php"); }Allows per-template override of the initial HTML structure .
-
HTML
<head>Compositioninclude_once(TEMPLATE_DIR . "inc/template_meta.php"); include_once("inc/panels/meta.php"); if (file_exists(TEMPLATE_DIR . $current_template_name . "_meta.php")) { include_once(TEMPLATE_DIR . $current_template_name . "_meta.php"); }Aggregates shared and template-specific
<meta>tags . -
Header & Navigation
include_once("inc/panels/header.php"); include_once("inc/panels/top_nav.php");Renders the top-of-page UI elements .
-
Content Injection
if (!in_array($currnt_template, $exclude_banner)) { include_once("inc/panels/small_banner.php"); } include_once(TEMPLATE_DIR . $current_template_name . "_content.php");Optionally shows a small banner and then the pageβs main content .
-
Footer
include_once("inc/panels/footer.php");Completes the page structure .
-
Profiler Panel (Optional)
if (PROFILER) { $pageLoadingTime = microtime(true) - $pageLoadingStartTime; $GLOBALS['BENCHMARKS']['total_execution_time'] = $pageLoadingTime; ?> <div class="profiler"> <!-- BENCHMARKS & QUERIES tables --> </div> <?php } ?>When
PROFILERistrue, it displays execution time, individual benchmarks, and sorted DB query log .
Profiler Details π
- Total Execution Time: Calculated from
$pageLoadingStartTimeto page render completion. - Benchmarks Table: Lists named timers (e.g., βDatabaseβ, βTemplate Loadβ) in a
<fieldset>with red legend. - Query Log Table: Shows each SQL statement sorted by time, with a blue legend citing
DB_NAMEand total queries/time.
Key Snippet
foreach ($GLOBALS['QueryLog']['TimeTaken'] as $idx => $time) {
echo "<tr><td>{$time}</td><td>{$GLOBALS['QueryLog']['Query'][$idx]}</td></tr>";
}
Configuration Variables π
TEMPLATE_DIR: Absolute path to the active template directory.$current_template_name: Identifies which template variant to load.$currnt_template: Used to determine if banners should be suppressed.$exclude_banner: Array of templates excluding the small banner.PROFILER: Boolean constant toggling the debug panel.DB_NAME: Database name displayed in profiler legend.
Related Files & Structure π
linuxfront-v2-logistics/
ββ inc/
β ββ config.php # Core settings & constants
β ββ panels/
β ββ header.php
β ββ top_nav.php
β ββ small_banner.php
β ββ footer.php
β ββ meta.php
ββ site_template_lastok-17-04-2014.php # β This file
ββ site_template.php # Earlier generic template
ββ popup_template.php # Layout for modal/pop-up pages
ββ route.php / route1.php # Front-controller routing requests
ββ other assets (labels, js, manifestsβ¦)
Each include under inc/panels/ provides a single responsibility (header, nav, banner, footer) for clean separation of concerns.
Usage π
- Front-Controller (
route.php) determines$currnt_file_nameand$current_template_name. - It then includes this template file to render the full page.
- Template fragments under
TEMPLATE_DIRsupply page-specific markup without altering the master layout.
Version Note π
This file is named with the suffix lastok-17-04-2014 to indicate the last known working revision on 17 April 2014. Legacy counterparts (e.g., 21-11-2012_site_template.php) share similar structure but lack the enhanced profiler logic.
By centralizing layout logic here, the application achieves a consistent look and feel, simplifies template swaps, and offers built-in performance insightsβall in a compact, modular, and maintainable fashion.