Restore getUserMemberStatus function to original implementation and fix database queries
This commit is contained in:
417
HEADER_MIGRATION_EXAMPLES.md
Normal file
417
HEADER_MIGRATION_EXAMPLES.md
Normal file
@@ -0,0 +1,417 @@
|
||||
# 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
|
||||
<?php require_once('header01.php'); ?>
|
||||
<!-- or -->
|
||||
<?php require_once('header02.php'); ?>
|
||||
```
|
||||
|
||||
### New Way (Single File + Config)
|
||||
```php
|
||||
<?php
|
||||
define('HEADER_VARIANT', '01'); // or '02'
|
||||
require_once('header.php');
|
||||
?>
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Pages Using Header 01 → Update These
|
||||
|
||||
Pages that currently use `header01.php` should be updated to use variant '01':
|
||||
|
||||
```php
|
||||
<?php
|
||||
// At the very top of the file, before any output
|
||||
define('HEADER_VARIANT', '01');
|
||||
require_once('header.php');
|
||||
?>
|
||||
|
||||
<!--- Rest of your page content --->
|
||||
```
|
||||
|
||||
**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
|
||||
<?php
|
||||
// At the very top of the file, before any output
|
||||
define('HEADER_VARIANT', '02');
|
||||
require_once('header.php');
|
||||
?>
|
||||
|
||||
<!--- Rest of your page content --->
|
||||
```
|
||||
|
||||
**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
|
||||
<?php require_once('header01.php'); ?>
|
||||
|
||||
<section class="page-title">
|
||||
<h1>Welcome</h1>
|
||||
</section>
|
||||
|
||||
<main>
|
||||
<!-- Your content here -->
|
||||
</main>
|
||||
|
||||
<?php require_once('footer.php'); ?>
|
||||
```
|
||||
|
||||
**After (using consolidated header.php):**
|
||||
```php
|
||||
<?php
|
||||
// Set variant at the top
|
||||
define('HEADER_VARIANT', '01');
|
||||
require_once('header.php');
|
||||
?>
|
||||
|
||||
<section class="page-title">
|
||||
<h1>Welcome</h1>
|
||||
</section>
|
||||
|
||||
<main>
|
||||
<!-- Your content here (unchanged) -->
|
||||
</main>
|
||||
|
||||
<?php require_once('footer.php'); ?>
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## Complete Page Example - Header 02
|
||||
|
||||
**Before (using header02.php):**
|
||||
```php
|
||||
<?php require_once('header02.php'); ?>
|
||||
|
||||
<section class="page-banner-area">
|
||||
<h1>Trip Details</h1>
|
||||
</section>
|
||||
|
||||
<main>
|
||||
<!-- Your content here -->
|
||||
</main>
|
||||
|
||||
<?php require_once('footer.php'); ?>
|
||||
```
|
||||
|
||||
**After (using consolidated header.php):**
|
||||
```php
|
||||
<?php
|
||||
// Set variant at the top
|
||||
define('HEADER_VARIANT', '02');
|
||||
require_once('header.php');
|
||||
?>
|
||||
|
||||
<section class="page-banner-area">
|
||||
<h1>Trip Details</h1>
|
||||
</section>
|
||||
|
||||
<main>
|
||||
<!-- Your content here (unchanged) -->
|
||||
</main>
|
||||
|
||||
<?php require_once('footer.php'); ?>
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 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
|
||||
<?php echo "<h1>Hello</h1>"; ?>
|
||||
<?php define('HEADER_VARIANT', '01'); ?>
|
||||
<?php require_once('header.php'); ?>
|
||||
<!-- Error: Can't modify headers after output -->
|
||||
```
|
||||
|
||||
### ✅ Correct: Define at Top
|
||||
```php
|
||||
<?php
|
||||
define('HEADER_VARIANT', '01');
|
||||
require_once('header.php');
|
||||
?>
|
||||
<!-- Now safe to use header functions -->
|
||||
```
|
||||
|
||||
### ❌ Mistake 2: Forgetting to Set Variant
|
||||
```php
|
||||
<?php require_once('header.php'); ?>
|
||||
<!-- Defaults to variant 01 -->
|
||||
```
|
||||
|
||||
### ✅ Correct: Always Specify
|
||||
```php
|
||||
<?php
|
||||
define('HEADER_VARIANT', '01'); // Explicit
|
||||
require_once('header.php');
|
||||
?>
|
||||
```
|
||||
|
||||
### ❌ Mistake 3: Including Old Files
|
||||
```php
|
||||
<?php
|
||||
define('HEADER_VARIANT', '01');
|
||||
require_once('header01.php'); // Wrong!
|
||||
?>
|
||||
```
|
||||
|
||||
### ✅ Correct: New File Only
|
||||
```php
|
||||
<?php
|
||||
define('HEADER_VARIANT', '01');
|
||||
require_once('header.php'); // Right!
|
||||
?>
|
||||
```
|
||||
|
||||
---
|
||||
|
||||
## 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
|
||||
<?php
|
||||
define('HEADER_VARIANT', '01');
|
||||
require_once('header.php');
|
||||
?>
|
||||
```
|
||||
|
||||
**Files using `header02.php`:**
|
||||
```php
|
||||
<?php
|
||||
define('HEADER_VARIANT', '02');
|
||||
require_once('header.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
|
||||
<?php require_once('header.php'); ?>
|
||||
<!-- No HEADER_VARIANT defined -->
|
||||
```
|
||||
|
||||
**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! 🚀
|
||||
Reference in New Issue
Block a user