# Header Consolidation - Migration Examples Quick reference for updating your pages to use the new consolidated header system. --- ## Quick Migration Pattern ### Old Way (Separate Files) ```php ``` ### New Way (Single File + Config) ```php ``` --- ## Pages Using Header 01 → Update These Pages that currently use `header01.php` should be updated to use variant '01': ```php ``` **Pages to update (that likely use header01):** - `index.php` - Home page - `about.php` - About page - `trips.php` - Trips listing - `events.php` - Events page - `blog.php` - Blog listing - `contact.php` - Contact page - Any pages with white menu --- ## Pages Using Header 02 → Update These Pages that currently use `header02.php` should use variant '02': ```php ``` **Pages to update (that likely use header02):** - `trip-details.php` - Trip detail pages - `tour-list.html` - Tour listing pages - Any pages with white/light background header - Pages with dark text welcome message --- ## Complete Page Example - Header 01 **Before (using header01.php):** ```php

Welcome

``` **After (using consolidated header.php):** ```php

Welcome

``` --- ## Complete Page Example - Header 02 **Before (using header02.php):** ```php

Trip Details

``` **After (using consolidated header.php):** ```php

Trip Details

``` --- ## Testing After Migration ### Test Variant 01 Pages ``` 1. Load page with header variant 01 2. Verify: ✅ Logo shows (white version) ✅ Welcome text is WHITE ✅ Full trips submenu visible on hover ✅ Members Area menu visible (if logged in as member) ✅ Security headers present (check Network tab) ✅ All admin menus show (if superadmin) ``` ### Test Variant 02 Pages ``` 1. Load page with header variant 02 2. Verify: ✅ Logo shows (dark version - logo-two.png) ✅ Welcome text is DARK (#111111) ✅ Trips menu has NO submenu ✅ Members Area menu NOT visible ✅ Security headers NOT present ✅ Page banner styles applied correctly ✅ Material Icons load correctly ``` --- ## Common Mistakes to Avoid ### ❌ Mistake 1: Defining Variant After Output ```php Hello"; ?> ``` ### ✅ Correct: Define at Top ```php ``` ### ❌ Mistake 2: Forgetting to Set Variant ```php ``` ### ✅ Correct: Always Specify ```php ``` ### ❌ Mistake 3: Including Old Files ```php ``` ### ✅ Correct: New File Only ```php ``` --- ## File-by-File Migration Checklist ### Step 1: Identify Current Header For each PHP file, check which header it's using: ```bash grep -r "require.*header0[12]" *.php ``` ### Step 2: Update Each File **Files using `header01.php`:** ```php ``` **Files using `header02.php`:** ```php ``` ### Step 3: Delete Old Files Once all files are updated and tested: ```bash rm header01.php rm header02.php ``` --- ## URL Parameter Alternative (For Testing) If you want to test both variants WITHOUT modifying each file: **In your page file:** ```php ``` **Then access via URL:** - `mypage.php?header=01` → Uses variant 01 - `mypage.php?header=02` → Uses variant 02 - `mypage.php` → Uses default (variant 01) --- ## Environment Variable Alternative (For DevOps) Update `header_config.php`: ```php if (!defined('HEADER_VARIANT')) { $variant = isset($_GET['header']) ? $_GET['header'] : getenv('HEADER_VARIANT'); $variant = $variant ?: '01'; define('HEADER_VARIANT', $variant); } ``` Then set in `.env`: ``` HEADER_VARIANT=02 ``` --- ## Batch Migration Script (Optional) If you have many files, create a migration script: ```bash #!/bin/bash # Find all PHP files using header01.php for file in $(grep -l "require_once.*header01" *.php); do sed -i "s/require_once('header01.php');/define('HEADER_VARIANT', '01');\nrequire_once('header.php');/" "$file" done # Find all PHP files using header02.php for file in $(grep -l "require_once.*header02" *.php); do sed -i "s/require_once('header02.php');/define('HEADER_VARIANT', '02');\nrequire_once('header.php');/" "$file" done echo "Migration complete!" ``` --- ## Verification Commands ### Verify All Files Updated ```bash # Should return empty (no old header includes) grep -r "header0[12].php" *.php ``` ### Verify New Includes ```bash # Should show all updated files grep -r "HEADER_VARIANT" *.php ``` ### Check for Remaining Issues ```bash # Look for any orphaned header01/header02 references grep -r "header0[12]" . --include="*.php" --include="*.html" ``` --- ## Performance Notes ### File Size Comparison - **Before:** header01.php (400 lines) + header02.php (400 lines) = 800 lines total - **After:** header.php (300 lines) + header_config.php (100 lines) = 400 lines total - **Savings:** 50% code reduction ### Load Time - **Before:** Loads one of two large files per page - **After:** Loads smaller consolidated file + config array - **Impact:** Negligible for most sites (PHP parses quickly) --- ## Success Criteria After migration, verify: - [ ] All pages load without errors - [ ] Header variant 01 pages look correct (white menu, etc.) - [ ] Header variant 02 pages look correct (dark header, etc.) - [ ] All navigation menus work - [ ] All user authentication works - [ ] Admin sections still visible to admins - [ ] No duplicate code between header files - [ ] Old header01.php and header02.php removed - [ ] Page load times unchanged - [ ] No errors in browser console --- ## Rollback Plan (If Needed) If something breaks: ```bash # Restore from git git checkout header01.php header02.php # Revert page changes git checkout *.php ``` Then investigate and re-test before trying again. --- ## Support **Question:** "Which variant should my page use?" **Answer:** Check what it currently uses (grep for header0X.php) **Question:** "Can I mix variants in one page?" **Answer:** No - define HEADER_VARIANT once at the top **Question:** "How do I add a new variant?" **Answer:** Add to header_config.php array, use `define('HEADER_VARIANT', '03')` **Question:** "Do I need to change footer.php?" **Answer:** No - footer.php remains unchanged --- ## Quick Summary ``` OLD: require_once('header01.php'); // or header02.php NEW: define('HEADER_VARIANT', '01'); require_once('header.php'); That's it! Your page will work exactly the same, but with zero code duplication. ``` Happy migrating! 🚀