📝 contact_template.php

Overview

The contact_template.php file serves as a layout wrapper for the “Contact Us” page within the linuxfront-v2-logistics application. It orchestrates the assembly of global configs, template-specific overrides, metadata, header, content, navigation, and footer into a complete XHTML document .

Purpose

  • Provide a consistent page structure across contact-related views
  • Dynamically include theme-specific template parts (e.g. top banner, meta, content)
  • Ensure separation of concerns between configuration, layout, and page content

Dependencies 🛠️

Component Role Source / Location
inc/config.php Defines constants like TEMPLATE_DIR, starts session inc/config.php
TEMPLATE_DIR/*.php (optional overrides) Template-specific “top” or “meta” partials e.g. <template>_top.php, <template>_meta.php
inc/template_meta.php Default <meta> tags, CSS/JS includes TEMPLATE_DIR/inc/template_meta.php
inc/panels/meta.php Additional shared <meta> code inc/panels/meta.php
inc/panels/header.php Site header markup inc/panels/header.php
TEMPLATE_DIR/<template>_content.php Page-specific main content e.g. contact_us/contact_us.php
inc/panels/right_nav.php Sidebar or right-hand navigation inc/panels/right_nav.php
inc/panels/footer.php Site footer markup inc/panels/footer.php

File Structure Breakdown

<?php
  // 1️⃣ Global config
  include_once("inc/config.php");

  // 2️⃣ Optional template-specific “top” partial
  if (file_exists(TEMPLATE_DIR . $current_template_name . "_top.php")) {
    include_once(TEMPLATE_DIR . $current_template_name . "_top.php");
  }
?>
<!DOCTYPE html PUBLIC ...>
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <?php
      // 3️⃣ Default + shared meta
      include_once(TEMPLATE_DIR . "inc/template_meta.php");
      include_once("inc/panels/meta.php");

      // 4️⃣ Optional template-specific “meta”
      if (file_exists(TEMPLATE_DIR . $current_template_name . "_meta.php")) {
        include_once(TEMPLATE_DIR . $current_template_name . "_meta.php");
      }
    ?>
  </head>
  <body>
    <div id="wrapper">
      <div id="theme_bg">
        <!-- 5️⃣ Site header -->
        <?php include_once("inc/panels/header.php"); ?>

        <div id="content_wrap">
          <h2 class="news">Comprehensive Freight Management System</h2>

          <!-- 6️⃣ Page content -->
          <?php include_once(TEMPLATE_DIR . $current_template_name . "_content.php"); ?>
        </div>

        <!-- 7️⃣ Right-hand navigation -->
        <?php include_once("inc/panels/right_nav.php"); ?>
      </div>

      <!-- 8️⃣ Footer -->
      <div id="footer_one">
        <?php include_once("inc/panels/footer.php"); ?>
      </div>
      <br clear="all" />
    </div>
  </body>
</html>

Template Assembly Flowchart

flowchart TD
  A[Start: include config.php] --> B{Exists <br/> <template>_top.php?}
  B -- Yes --> C[include <template>_top.php]
  B -- No  --> D[skip]
  C & D --> E[HTML `<head>`]
  E --> F[include template_meta.php]
  E --> G[include panels/meta.php]
  E --> H{Exists <template>_meta.php?}
  H -- Yes --> I[include <template>_meta.php]
  H -- No  --> J[skip]
  I & J --> K[Start `<body>` wrapper]
  K --> L[include panels/header.php]
  L --> M[Render `<h2>` title]
  M --> N[include <template>_content.php]
  N --> O[include panels/right_nav.php]
  O --> P[include panels/footer.php]
  P --> Q[End]

This wrapper pattern repeats across other layouts in the codebase:

  • site_template.php: adds inc/panels/top_nav.php and conditional banners
  • popup_template.php: renders content in a popup container with class="popup_body"
  • 21-11-2012_site_template.php: legacy version with nearly identical structure

Configuration Constants

The inc/config.php sets up critical constants:

  • TEMPLATE_DIR: filesystem path to template files
  • SITE_DIR: base path for site resources
  • JS/CSS arrays: queued for inclusion in <head>

Best Practices & Notes

  • Guarded includes (file_exists) allow template overrides without errors.
  • Separation of concerns: global config vs. shared panels vs. page content.
  • Extendable: adding a new template simply requires dropping <template>_top.php, <template>_meta.php, or <template>_content.php into TEMPLATE_DIR.

By following this consistent composition strategy, the application ensures maintainability, theming flexibility, and clear separation between layout and content.