Ad Area System Guide

Ad Area System Guide

The Ad Area System is a conditional advertising feature that displays promotional content only when the CMS is in hosting service mode. This system provides hosting providers with a professional way to showcase their services while maintaining a clean experience for self-hosted users.

๐Ÿ“‹ Table of Contents

๐ŸŽฏ Overview

The Ad Area System provides:

When Ads Are Visible

CMS Mode Ad Area Status
Full Featured โŒ Hidden
Hosting Service (Plugin Mode) โœ… Visible
Hosting Service (No Plugin Management) โœ… Visible

๐Ÿ”ง How It Works

Conditional Logic

The ad area uses template conditional syntax to determine visibility:

{{#if isHostingServiceMode}}
<div class="ad-area">
    <!-- Ad content only visible in hosting service modes -->
</div>
{{/if}}

Template Variables

The system provides these variables to templates:

Include System

Themes include the ad area using:

{{include=ad-area.html}}

๐Ÿš€ CMS Mode Integration

Template Data

The main index.php automatically includes CMS mode information:

$templateData = [
    // ... other data ...
    'cmsMode' => $cmsModeManager->getCurrentMode(),
    'isHostingServiceMode' => $cmsModeManager->isRestricted(),
    'cmsModeName' => $cmsModeManager->getModeName(),
];

Mode Detection

The system automatically detects the current mode from config/cms_mode.json:

{
    "mode": "hosting-service-plugins"
}

๐Ÿ“ Template System

Ad Area Template

Located at themes/ad-area.html, the template includes:

Template Structure

{{#if isHostingServiceMode}}
<div class="ad-area">
    <!-- Background Pattern -->
    <div class="ad-background"></div>

    <!-- Ad Content -->
    <div class="ad-content">
        <h3>๐Ÿš€ Premium Hosting Features</h3>
        <p>Unlock the full potential of your website...</p>

        <!-- Feature Highlights -->
        <div class="feature-tags">
            <span>โšก Fast Performance</span>
            <span>๐Ÿ”’ Enhanced Security</span>
            <span>๐Ÿ“ฑ Mobile Optimized</span>
        </div>

        <!-- Call to Action -->
        <a href="#" class="cta-button">Learn More โ†’</a>
    </div>

    <!-- Close Button -->
    <button class="close-button">ร—</button>
</div>
{{/if}}

๐ŸŽจ Theme Integration

Automatic Inclusion

All themes automatically include the ad area. The system has been integrated with:

Positioning

The ad area is positioned right after the header in all themes for maximum visibility:

{{module=header.html}}
{{include=ad-area.html}}
<main>
    <!-- Page content -->
</main>

๐ŸŽฏ Customization

Modifying Ad Content

Edit themes/ad-area.html to customize:

Styling Customization

The ad area uses inline styles for consistency, but you can:

  1. Add CSS Classes: Modify the template to use theme-specific CSS
  2. Theme Integration: Create theme-specific ad area variations
  3. Responsive Design: Adjust breakpoints for different screen sizes

Content Localization

Support multiple languages by creating localized versions:

themes/
โ”œโ”€โ”€ ad-area.html          # Default (English)
โ”œโ”€โ”€ ad-area-es.html       # Spanish
โ”œโ”€โ”€ ad-area-fr.html       # French
โ””โ”€โ”€ ad-area-de.html       # German

๐Ÿงช Testing

Testing in Full Featured Mode

  1. Ensure CMS is in "full-featured" mode
  2. Navigate to any page
  3. Verify ad area is NOT visible

Testing in Hosting Service Mode

  1. Access admin panel: /admin
  2. Navigate to CMS Mode section
  3. Change to "Hosting Service (Plugin Mode)"
  4. Refresh any page
  5. Verify ad area is visible

Testing Across Themes

  1. Change CMS mode to hosting service mode
  2. Switch between different themes
  3. Verify ad area appears consistently
  4. Test responsive behavior on different screen sizes

Demo Page

Use the built-in demo page at /ad-demo to test the feature.

๐Ÿ”ง Troubleshooting

Common Issues

Ad Area Not Visible

Problem: Ad area doesn't appear in hosting service mode

Solutions:

  1. Check CMS mode: config/cms_mode.json
  2. Verify template includes: {{include=ad-area.html}}
  3. Check template syntax: {{#if isHostingServiceMode}}
  4. Review browser console for JavaScript errors

Ad Area Always Visible

Problem: Ad area appears even in full-featured mode

Solutions:

  1. Verify CMS mode is "full-featured"
  2. Check template conditional logic
  3. Clear browser cache
  4. Verify isHostingServiceMode variable value

Styling Issues

Problem: Ad area doesn't match theme design

Solutions:

  1. Check CSS conflicts in theme stylesheets
  2. Verify responsive breakpoints
  3. Test in different browsers
  4. Review theme-specific CSS overrides

Debug Information

Add debug output to verify variables:

<!-- Debug: Remove in production -->
<div style="background: #f0f0f0; padding: 10px; margin: 10px; font-family: monospace;">
    <strong>Debug Info:</strong><br>
    CMS Mode: full-featured<br>
    Is Hosting Service: false<br>
    Mode Name: Full Featured
</div>

๐Ÿš€ Advanced Features

A/B Testing

Implement different ad variations:

{{#if isHostingServiceMode}}
    {{#if themeOptions.adVariation}}
        {{include=ad-area-variation-b.html}}
    {{else}}
        {{include=ad-area.html}}
    {{/if}}
{{/if}}

Analytics Integration

Track ad performance:

<script>
document.addEventListener('DOMContentLoaded', function() {
    const adArea = document.querySelector('.ad-area');
    if (adArea) {
        // Track ad impression
        gtag('event', 'ad_impression', {
            'event_category': 'advertising',
            'event_label': 'hosting_service_ad'
        });

        // Track close button clicks
        const closeBtn = adArea.querySelector('.close-button');
        closeBtn.addEventListener('click', function() {
            gtag('event', 'ad_closed', {
                'event_category': 'advertising',
                'event_label': 'hosting_service_ad'
            });
        });
    }
});
</script>

Dynamic Content

Load ad content dynamically:

{{#if isHostingServiceMode}}
<div class="ad-area" data-ad-type="hosting-service">
    <div class="ad-content">
        <h3>{{themeOptions.adHeadline}}</h3>
        <p>{{themeOptions.adDescription}}</p>
        <a href="{{themeOptions.adLink}}" class="cta-button">
            {{themeOptions.adButtonText}}
        </a>
    </div>
</div>
{{/if}}

User Preferences

Remember user ad preferences:

<script>
// Check if user has dismissed ads
if (localStorage.getItem('adsDismissed') === 'true') {
    document.querySelector('.ad-area')?.remove();
}

// Handle close button
document.querySelector('.close-button')?.addEventListener('click', function() {
    localStorage.setItem('adsDismissed', 'true');
    this.parentElement.remove();
});
</script>

๐Ÿ“š Related Documentation

๐Ÿ†˜ Getting Help

If you need assistance with the Ad Area System:

  1. Check the troubleshooting section above
  2. Verify CMS mode settings in the admin panel
  3. Review template syntax for conditional logic
  4. Test with different themes to isolate issues
  5. Consult the community for additional support

Happy advertising! ๐ŸŽ‰

This documentation is maintained by the FearlessCMS community. Last updated: January 2024