I'm trying to use one header.php to process both my public pages and my admin pages using conditional statements. I can get this technique to work when I use an include, but I learned a different technique for including files using a function and now my conditional statements for admin and public are not working.
So this code is at the top of my header.php wrapped in php tag.
if (!isset($layout_context)) {
$layout_context = "public";
}
Then in my header tag I have sections of code like this
<?php if($layout_context == "public") { ?>
<header id="home">
<?php ; } elseif($layout_context == "admin") { ?>
<header id="cms-pages">
<?php ; } ?>
Then in all my pages I put this code at the top
<?php $layout_context = "public"; ?>
or
<?php $layout_context = "admin"; ?>
When I use this code:
<?php include("includes/layouts/header.php"); ?>
I can get those conditional public and admin codes to work, but when I try and use this technique to include my header.php
<?php include_layout_template('header-admin.php'); ?>
function lives in the functions.php in the includes folder.
function include_layout_template($template="") {
include(SITE_ROOT.DS.'includes'.DS.'layouts'.DS.$template);
}
I can't get the conditional code to work. Does anyone know why that might be?
Thank you :)