Banner Zones
Overview
The Banner Zones page allows administrators to create and manage advertising placement zones (also called "placements" or "slots") throughout the website. Each zone represents a specific location where banners can be displayed.
Key Features
- Create unlimited banner placement zones
- Define maximum banner limits per zone
- Assign unique zone codes for template integration
- Track banner counts and statistics per zone
- Toggle zone status (active/inactive)
- Copy existing zones to create new ones quickly
How Zones Work
- Create a Zone - Define a placement location with a unique code
- Assign Banners - Banners are assigned to zones via the Add Banner page
- Display in Templates - Use zone codes in frontend templates to display banners
- Track Performance - Monitor which zones perform best
System Requirements
PHP Extensions Required
PHP Functions Used
Database Requirements
- MySQL/MariaDB with InnoDB engine (for transaction support)
- User must have SELECT, INSERT, UPDATE, DELETE permissions on
tblBannerPlacements
External Dependencies
Accessing the Page
Navigation Path
- Log into the admin panel
- Navigate to Advertising section in the main menu
- Click Banner Zones (or Placements)
Direct URL
https://yourdomain.com/ct/admin/bannerzones.php
Required Permissions
- Must be logged in as an administrator
- Session must be active with valid authentication
[Screenshot: Admin sidebar showing Advertising menu with Banner Zones option highlighted]
Page Layout
Header Section
The page header contains:
[Screenshot: Banner Zones page header with Add Zone button]
Statistics Cards
Four summary cards display at the top of the page:
[Screenshot: Statistics cards showing zone and banner counts]
Zone List Table
The main content area displays a responsive table with all zones:
[Screenshot: Zone list table showing multiple zones with statistics]
Zone Management
Understanding Zone Codes
Zone codes are unique identifiers used to reference zones in frontend templates. They follow strict formatting rules:
Valid Zone Code Format:
- Uppercase letters (A-Z)
- Numbers (0-9)
- Underscores ()
- No spaces or special characters
Examples:
/^[A-Z0-9]+$/
Banner Count Display
Each zone shows its banner utilization:
Banners: 2 / 5 (40%)
This indicates:
- 2 banners currently assigned
- 5 maximum banners allowed
- 40% utilization rate
Status Toggle
Each zone has an active/inactive toggle switch:
- Green (Active) - Zone can display banners on the frontend
- Gray (Inactive) - Zone is disabled, no banners will display
Adding a New Zone
Step 1: Open the Add Zone Modal
Click the green "Add Zone" button in the page header.
[Screenshot: Add Zone button highlighted]
Step 2: Fill in Zone Details
The modal form contains the following fields:
Zone Name (Required)
Zone Code (Required)
Description (Optional)
Max Banners (Required)
This setting controls how many banners can be assigned to this zone. If rotation is implemented:
- 1 = Single static banner
- 2+ = Multiple banners for rotation
Active Status
When checked, the zone is immediately active and can display banners.
Step 3: Save the Zone
Click the "Save Zone" button to create the zone.
Success Response:
- Modal closes automatically
- Zone list refreshes to show the new zone
- Success toast notification appears
Error Response:
- Error message displays in the modal
- Form remains open for correction
- Common errors: duplicate zone code, missing required fields
[Screenshot: Add Zone modal with filled form fields]
Editing Zones
Accessing Edit Mode
- Find the zone in the list table
- Click the pencil icon (Edit) button in the Actions column
[Screenshot: Edit button highlighted in Actions column]
Edit Modal
The edit modal is identical to the add modal but pre-populated with existing zone data:
- Zone Name - Current name (editable)
- Zone Code - Current code (editable, but see warning below)
- Description - Current description (editable)
- Max Banners - Current limit (editable)
- Active Status - Current status (editable)
Saving Changes
Click "Save Zone" to apply changes. The zone list will refresh automatically.
[Screenshot: Edit Zone modal with existing zone data]
Copying Zones
Using the Copy Feature
The copy feature allows you to quickly create a new zone based on an existing one:
- Find the source zone in the list
- Click the copy icon (Copy) button in the Actions column
- A new Add Zone modal opens with pre-filled data from the source zone
What Gets Copied
[Screenshot: Copy Zone modal showing pre-filled data with empty zone code field]
Copy Use Cases
- Creating similar zones for different pages (e.g.,
SIDEBARTOPHOMEPAGE,SIDEBARTOPVIDEOS) - Setting up test zones alongside production zones
- Creating backup zones before making changes
Deleting Zones
Delete Process
- Find the zone in the list
- Click the trash icon (Delete) button in the Actions column
- Confirm the deletion in the popup dialog
Confirmation Dialog
A confirmation dialog appears with the message:
Are you sure you want to delete this zone?
All banners assigned to this zone will become unassigned.
What Happens to Assigned Banners
When a zone is deleted:
The zone record is removed from tblBannerPlacements
- All banners previously assigned to this zone have their
placementidset to NULL - Banners are NOT deleted, only unassigned
- Unassigned banners can be reassigned to other zones
Delete Restrictions
Deletion will fail if:
- Database transaction fails
- User lacks delete permissions
- CSRF token is invalid
[Screenshot: Delete confirmation dialog]
Zone Code Implementation
Using Zone Codes in Templates
Zone codes are used in frontend template files to display banners. Here's how to implement them:
PHP Implementation Example
<?php
// Include banner display function
requireonce 'includes/bannerfunctions.php';
// Display banners for a specific zone
echo displayBannerZone('SIDEBARTOP');
?>
Sample Banner Display Function
function displayBannerZone($zonecode) {
global $conn;
// Get zone info
$zonequery = "SELECT placementid, isactive FROM tblBannerPlacements
WHERE zonecode = ? AND isactive = 1";
$stmt = mysqliprepare($conn, $zonequery);
mysqlistmtbindparam($stmt, 's', $zonecode);
mysqlistmtexecute($stmt);
$zoneresult = mysqlistmtgetresult($stmt);
if (!$zone = mysqlifetchassoc($zoneresult)) {
return ''; // Zone not found or inactive
}
// Get active banners for this zone
$bannerquery = "SELECT FROM tblBannerAssets
WHERE placementid = ? AND status = 'active'
ORDER BY RAND() LIMIT 1";
$stmt = mysqliprepare($conn, $bannerquery);
mysqlistmtbindparam($stmt, 'i', $zone['placementid']);
mysqlistmtexecute($stmt);
$bannerresult = mysqlistmtgetresult($stmt);
if ($banner = mysqlifetchassoc($bannerresult)) {
// Return banner HTML
return renderBanner($banner);
}
return '';
}
Template Integration Examples
Header Zone:
<header>
<nav><!-- Navigation --></nav>
<div class="header-banner-zone">
<?php echo displayBannerZone('HEADERBANNER'); ?>
</div>
</header>
Sidebar Zone:
<aside class="sidebar">
<div class="banner-slot">
<?php echo displayBannerZone('SIDEBARTOP'); ?>
</div>
<!-- Other sidebar content -->
<div class="banner-slot">
<?php echo displayBannerZone('SIDEBARBOTTOM'); ?>
</div>
</aside>
Video Player Zone:
<div class="video-container">
<video id="player"><!-- Video --></video>
</div>
<div class="below-player-banner">
<?php echo displayBannerZone('VIDEOBELOW'); ?>
</div>
Best Practices
Zone Naming Conventions
Recommended Format: [LOCATION][POSITION][SIZE/TYPE]
Zone Planning
Before creating zones, plan your advertising layout:
- Identify all banner locations on your website
- Document dimensions required for each location
- Determine rotation needs (single vs multiple banners)
- Consider device targeting (desktop, mobile, tablet)
- Group similar locations under common zone codes if appropriate
Performance Considerations
Caching Recommendations:
- Cache banner output for 5-15 minutes
- Invalidate cache when banners are updated
- Use separate caches for different zones
Zone Limits
Troubleshooting
Common Issues
Zone Code Already Exists
Error: "Zone code already exists"
Cause: Attempting to create or update a zone with a code that's already in use.
Solution:
- Check existing zones for the duplicate code
- Choose a different, unique code
- If updating, verify you're not accidentally using another zone's code
Zone Not Displaying Banners
Symptoms: Zone exists but no banners appear on frontend.
Checklist:
- ☐ Is the zone active? (Check status toggle)
- ☐ Are banners assigned to this zone? (Check banner count)
- ☐ Are assigned banners active? (Check banner status)
- ☐ Is the zone code correct in templates? (Case-sensitive check)
- ☐ Is the display function working? (Test with debug output)
SIDEBARTOP is different from sidebartop.
Cannot Delete Zone
Error: "Failed to delete zone"
Possible Causes:
- Database transaction failed
- Foreign key constraints preventing deletion
- CSRF token expired
Solution:
- Refresh the page and try again
- Check database error logs
- Verify user has delete permissions
Max Banners Limit Reached
Symptoms: Cannot assign more banners to a zone.
Solution:
- Edit the zone and increase the max banners limit
- Or remove existing banners from the zone
- Or create a new zone for additional banners
Database Queries for Debugging
Check Zone Status
SELECT placementid, placementname, zonecode, isactive, maxbanners
FROM tblBannerPlacements
WHERE zonecode = 'YOURZONECODE';
Count Banners per Zone
SELECT
p.zonecode,
p.placementname,
p.maxbanners,
COUNT(b.assetid) as assignedbanners
FROM tblBannerPlacements p
LEFT JOIN tblBannerAssets b ON p.placementid = b.placementid
GROUP BY p.placementid
ORDER BY p.zonecode;
Find Zones with No Banners
SELECT p.zonecode, p.placementname
FROM tblBannerPlacements p
LEFT JOIN tblBannerAssets b ON p.placementid = b.placementid
WHERE b.assetid IS NULL;
Find Unassigned Banners
SELECT assetid, bannername, status
FROM tblBannerAssets
WHERE placementid IS NULL;
Translatable Strings
The following strings should be added to backendtranslations.md for internationalization:
Page Title and Navigation
bannerzonestitle = "Banner Zones"
bannerzonesdescription = "Manage advertising placement zones"
Buttons and Actions
btnaddzone = "Add Zone"
btnsavezone = "Save Zone"
btneditzone = "Edit"
btncopyzone = "Copy"
btndeletezone = "Delete"
btncancel = "Cancel"
Form Labels
labelzonename = "Zone Name"
labelzonecode = "Zone Code"
labeldescription = "Description"
labelmaxbanners = "Max Banners"
labelactive = "Active"
labelstatus = "Status"
Table Headers
thzonename = "Zone Name"
thzonecode = "Zone Code"
thdescription = "Description"
thbanners = "Banners"
thstatus = "Status"
thactions = "Actions"
Statistics Cards
stattotalzones = "Total Zones"
statactivezones = "Active Zones"
statinactivezones = "Inactive Zones"
stattotalbanners = "Total Banners"
Messages and Notifications
msgzonesaved = "Zone saved successfully"
msgzonedeleted = "Zone deleted successfully"
msgzonestatusupdated = "Zone status updated"
msgconfirmdelete = "Are you sure you want to delete this zone?"
msgdeletewarning = "All banners assigned to this zone will become unassigned."
Error Messages
errorzonenotfound = "Zone not found"
errorzonecodeexists = "Zone code already exists"
errorzonecodeinvalid = "Zone code must contain only uppercase letters, numbers, and underscores"
errorzonenamerequired = "Zone name is required"
errorzonecoderequired = "Zone code is required"
errormaxbannersinvalid = "Max banners must be a positive number"
errordeletefailed = "Failed to delete zone"
errorsavefailed = "Failed to save zone"
Placeholders
placeholderzonename = "Enter zone name"
placeholderzonecode = "e.g., SIDEBARTOP"
placeholderdescription = "Optional description of this zone"
placeholdermaxbanners = "Enter maximum banners"
Help Text
helpzonecode = "Unique code used in templates. Use uppercase letters, numbers, and underscores only."
helpmaxbanners = "Maximum number of banners that can be assigned to this zone."
helpactive = "Only active zones will display banners on the frontend."
Modal Titles
modaladdzone = "Add New Zone"
modaleditzone = "Edit Zone"
Related Documentation
- Banner Management - View and manage all banners
- Add Banner - Create and edit banners
- Admin Guide - Main administration guide
Changelog
This documentation is part of the ComusThumbz Admin Guide series.*