# Comparison Pages Migration Guide


**Last Updated:** 2025-11-20

Guide for updating old design comparison pages (like `compare_flairhr.php`) to the new card-based design (like `compare_awork.php`, `compare_askdante.php`, etc.).

## Overview

**Old Design:** Table-based comparison layout  
**New Design:** Card-based OMR-style comparison grid with enhanced features

## Key Differences

### Layout Structure

**Old Design:**

- Uses HTML `<table>` element
- Simple 3-column table (Feature | Ordio | Competitor)
- Basic styling with `comparison-table` class

**New Design:**

- Uses card-based grid layout (`comparison-grid`)
- Two side-by-side cards (`ordio-card` and `personio-card`)
- Enhanced features: ratings, pricing, expandable details
- Height synchronization between columns

### Visual Design

**Old Design:**

- Flat table layout
- Basic checkmarks and text
- Minimal visual hierarchy

**New Design:**

- Card-based with shadows and borders
- Star ratings with distribution charts
- Circular rating indicators
- Pricing cards
- Expandable detail sections
- Better visual hierarchy

## Migration Checklist

### 1. Update Comparison Section Structure

**Replace:**

```php
<table class="min-w-full divide-y divide-[#EDEFF3] text-sm sm:text-base comparison-table">
    <thead>
        <tr>
            <th>Funktion</th>
            <th>ordio</th>
            <th>{competitor}</th>
        </tr>
    </thead>
    <tbody>
        <!-- Table rows -->
    </tbody>
</table>
```

**With:**

```php
<div class="comparison-grid" x-data="{ ordioDetailsHeight: 0 }" @height-changed="ordioDetailsHeight = $event.detail.height">
    <!-- Ordio Column -->
    <div class="bg-white rounded-2xl shadow-lg border border-gray-100 overflow-hidden ordio-card comparison-card">
        <div class="bg-ordio-blue px-8 py-6">
            <!-- Ordio header -->
        </div>
        <div class="p-8">
            <div class="space-y-6">
                <?php include '../components/ordio_comparison_content.php'; ?>
                <!-- Star Rating Distribution -->
                <!-- Ratings Section -->
                <!-- Pricing Section -->
                <!-- CTA Buttons -->
            </div>
        </div>
    </div>
    <!-- Competitor Column -->
    <div class="bg-white rounded-2xl shadow-lg border border-gray-100 overflow-hidden personio-card comparison-card">
        <!-- Competitor content -->
    </div>
</div>
```

### 2. Add Ordio Column Content

**Required Sections:**

1. **Header with Logo and Rating**

   ```php
   <div class="bg-ordio-blue px-8 py-6">
       <div class="flex items-center justify-between">
           <div class="flex items-center">
               <div class="w-32 h-8 flex items-center justify-start">
                   <img src="/html/images/ordio_white.svg" alt="Ordio" class="max-h-8 max-w-full object-contain" width="160" height="32" fetchpriority="high">
               </div>
           </div>
           <div class="text-right">
               <!-- Star rating display -->
           </div>
       </div>
   </div>
   ```

2. **Ordio Comparison Content Include**

   ```php
   <?php include '../components/ordio_comparison_content.php'; ?>
   ```

3. **Star Rating Distribution**

   - Copy from `compare_awork.php` lines 722-791
   - Update rating percentages and counts

4. **Ratings Section (Einschätzungen Reviewer)**

   - Copy from `compare_awork.php` lines 794-871
   - Update rating values

5. **Pricing Section**

   - Copy from `compare_awork.php` lines 874-914
   - Update pricing if needed

6. **CTA Buttons**
   ```php
   <div class="text-center">
       <div class="flex flex-col sm:flex-row gap-4 justify-center items-center">
           <button data-event-type="button_click" data-event-name="Kostenlos testen (Comparison)" @click="modelOpen = true; modalContentTitle = 'Jetzt kostenlos testen'; modalContentButton = 'Kostenlos und unverbindlich testen'" class="bg-ordio-blue hover:bg-blue-700 text-white font-medium py-3 px-8 rounded-lg transition-colors duration-200 shadow-lg hover:shadow-xl">
               Kostenlos testen
           </button>
           <a href="/preise" data-event-type="button_click" data-event-name="View Plans (Comparison)" class="bg-white hover:bg-gray-50 text-ordio-blue border-2 border-ordio-blue font-medium py-3 px-8 rounded-lg transition-colors duration-200 shadow-lg hover:shadow-xl">
               Pläne ansehen
           </a>
       </div>
   </div>
   ```

### 3. Update Competitor Column

**Structure:**

```php
<div class="bg-white rounded-2xl shadow-lg border border-gray-100 overflow-hidden personio-card comparison-card">
    <div class="bg-gray-600 px-8 py-6">
        <!-- Competitor header with logo and rating -->
    </div>
    <div class="p-8">
        <div class="space-y-6">
            <!-- Product Description -->
            <div class="mb-6">
                <p class="text-gray-600 leading-relaxed">
                    {Competitor description}
                </p>
            </div>

            <!-- Competitor Details (Expandable) -->
            <div class="mb-6" x-data="{ open: false }" x-init="...">
                <!-- Expandable details section -->
            </div>

            <!-- Star Rating Distribution -->
            <!-- Ratings Section -->
            <!-- Pricing Section -->
        </div>
    </div>
</div>
```

**Key Elements:**

1. **Header Background Color**

   - Use `bg-gray-600` or competitor brand color
   - Match competitor branding if known

2. **Competitor Logo**

   ```php
   <img src="/v2/img/alternativen/{competitor}-vergleich-logo-160w.webp"
        srcset="/v2/img/alternativen/{competitor}-vergleich-logo-160w.webp 160w,
                /v2/img/alternativen/{competitor}-vergleich-logo-320w.webp 320w"
        sizes="(max-width: 640px) 160px, 160px"
        alt="{competitor}"
        class="max-h-8 max-w-full object-contain"
        width="160"
        height="32"
        fetchpriority="high">
   ```

3. **Competitor Rating**

   - Update star rating display
   - Update rating value and count

4. **Expandable Details**
   - Copy structure from `compare_awork.php` lines 980-1065
   - Update with competitor-specific features

### 4. Update CSS Include

**Ensure comparison-pages.css is included:**

```php
<link rel="stylesheet" href="/v2/css/comparison-pages.css?v=<?php echo filemtime($_SERVER['DOCUMENT_ROOT'] . '/v2/css/comparison-pages.css'); ?>" media="print" onload="this.media='all'">
<noscript><link rel="stylesheet" href="/v2/css/comparison-pages.css"></noscript>
```

### 5. Add Alpine.js Support

**Ensure Alpine.js is loaded** (should be included via `head.php`):

```php
<?php
$aosScript = "true";
$swiperScript = "false";
include '../base/head.php';
?>
```

**Add Alpine.js data attributes:**

```php
<div class="comparison-grid" x-data="{ ordioDetailsHeight: 0 }" @height-changed="ordioDetailsHeight = $event.detail.height">
```

### 6. Update Section Wrapper

**Old:**

```php
<div class="max-w-4xl mx-auto mt-4 mb-16 px-4">
    <div class="overflow-x-auto rounded-2xl shadow-lg border border-[#EDEFF3] bg-white">
        <table class="...">
```

**New:**

```php
<section>
    <div class="text-center p-10 px-6 lg:px-20 pt-16 bg-[#fbfbfb] overflow-hidden">
        <!-- Section header -->
    </div>
    <div class="max-w-7xl mx-auto mt-8 mb-16 px-4">
        <div class="comparison-grid" x-data="...">
```

### 7. Update Comparison Section Header

**Add:**

```php
<div class="text-center p-10 px-6 lg:px-20 pt-16 bg-[#fbfbfb] overflow-hidden">
    <div class="max-w-7xl mx-auto">
        <div class="max-w-2xl mx-auto">
            <div class="mx-auto w-[120px] font-inter600 text-xs bg-white px-5 py-3 mb-9 rounded-full uppercase shadow-sm">
                Vergleich
            </div>
            <h2 class="text-5xl sm:text-7xl font-gilroybold leading-[102%] tracking-[-1.5px] mb-6 inline-block p-1 text-[#333333]">
                Ordio vs. {Competitor}
                <br><span class="block sm:inline text-2xl sm:text-4xl font-inter500 font-normal align-middle">Funktionsvergleich im Überblick</span>
            </h2>
        </div>
    </div>
</div>
```

### 8. Verify Image Assets

**Check for required images:**

```bash
ls -la v2/img/alternativen/{competitor}-vergleich-logo-*.webp
```

**If missing, generate variants:**

```bash
node scripts/generate_responsive_logos.js
```

### 9. Update Schema

**Ensure Table schema includes Product schemas:**

```json
{
    "@type": "Table",
    "mainEntity": [
        {
            "@type": "Product",
            "name": "Ordio",
            "aggregateRating": { ... },
            "offers": { ... }
        },
        {
            "@type": "Product",
            "name": "{Competitor}",
            "aggregateRating": { ... },
            "offers": { ... }
        }
    ]
}
```

### 10. Test and Validate

**Testing Checklist:**

- [ ] Page loads without errors
- [ ] Comparison grid displays correctly
- [ ] Columns have equal heights
- [ ] Expandable sections work
- [ ] Ratings display correctly
- [ ] Images load with correct srcset
- [ ] Responsive design works (mobile/tablet/desktop)
- [ ] Schema validates (Google Rich Results Test)
- [ ] No console errors
- [ ] Performance acceptable (LCP < 2.5s)

## Code Comparison Examples

### Example 1: Feature Row

**Old Design:**

```php
<tr class="comparison-row hover:bg-gray-50 transition-colors duration-200">
    <td class="py-4 px-8 font-inter500">
        <a href="/schichtplan" class="text-[#333] hover:text-ordio-blue transition font-inter500">
            Schichtplanung
        </a>
    </td>
    <td class="py-4 px-4 text-center">
        <span class="inline-flex items-center px-3 py-1 rounded-full bg-green-100 text-green-700 font-inter500">
            <svg class="w-4 h-4 mr-1 text-green-500" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                <path d="M5 13l4 4L19 7"/>
            </svg>
            Inklusive
        </span>
    </td>
    <td class="py-4 px-4 text-center">
        <span class="inline-flex items-center px-3 py-1 rounded-full text-[#333] font-inter500">
            <svg class="w-4 h-4 mr-1 text-[#333]" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                <path d="M5 13l4 4L19 7"/>
            </svg>
            Feature description
        </span>
    </td>
</tr>
```

**New Design:**

Features are now displayed in expandable sections within cards, not as table rows. See `ordio_comparison_content.php` for Ordio features and competitor column for competitor features.

### Example 2: Comparison Container

**Old Design:**

```php
<div class="max-w-4xl mx-auto mt-4 mb-16 px-4">
    <div class="overflow-x-auto rounded-2xl shadow-lg border border-[#EDEFF3] bg-white">
        <table class="min-w-full divide-y divide-[#EDEFF3] text-sm sm:text-base comparison-table">
```

**New Design:**

```php
<div class="max-w-7xl mx-auto mt-8 mb-16 px-4">
    <div class="comparison-grid" x-data="{ ordioDetailsHeight: 0 }" @height-changed="ordioDetailsHeight = $event.detail.height">
```

## Common Issues and Solutions

### Issue: Columns Not Equal Height

**Solution:** Ensure Alpine.js height synchronization is working:

```php
<div class="comparison-grid" x-data="{ ordioDetailsHeight: 0 }" @height-changed="ordioDetailsHeight = $event.detail.height">
```

Check that components dispatch `height-changed` events.

### Issue: Expandable Sections Not Working

**Solution:** Ensure Alpine.js is loaded and `x-data` attributes are correct:

```php
<div x-data="{ open: false }" x-init="...">
    <button @click="open = !open">...</button>
    <div x-show="open" x-transition>...</div>
</div>
```

### Issue: Images Not Displaying

**Solution:** Verify image paths and variants exist:

```bash
ls -la v2/img/alternativen/{competitor}-vergleich-logo-*.webp
```

Generate variants if missing:

```bash
node scripts/generate_responsive_logos.js
```

### Issue: Styling Looks Broken

**Solution:** Ensure `comparison-pages.css` is included:

```php
<link rel="stylesheet" href="/v2/css/comparison-pages.css?v=<?php echo filemtime($_SERVER['DOCUMENT_ROOT'] . '/v2/css/comparison-pages.css'); ?>" media="print" onload="this.media='all'">
```

## Step-by-Step Migration Process

1. **Backup existing page**

   ```bash
   cp v2/pages/compare_{competitor}.php v2/pages/compare_{competitor}.php.backup
   ```

2. **Choose and copy the appropriate template**

   Choose based on whether the competitor needs a Details section:
   - **`compare_template_details.php`** - Use when competitor has detailed features/integrations to showcase
   - **`compare_template_nodetails.php`** - Use when competitor is well-known or doesn't need detailed feature breakdown

   ```bash
   # For pages with Details section:
   cp v2/pages/compare_template_details.php v2/pages/compare_{competitor}_new.php
   
   # OR for pages without Details section:
   cp v2/pages/compare_template_nodetails.php v2/pages/compare_{competitor}_new.php
   ```

3. **Update competitor-specific content**

   - Meta tags
   - Schema data
   - Competitor name and description
   - Competitor logo paths (change `template_details-vergleich-logo-160w.webp` or `template_nodetails-vergleich-logo-160w.webp` to `{competitor}-vergleich-logo-160w.webp`)
   - Competitor ratings and pricing
   - If using Details template: Update Details section (features, integrations, special characteristics, button text)
   - FAQ content

4. **Test locally**

   ```bash
   php -S localhost:8003 -t .
   # Visit http://localhost:8003/v2/pages/compare_{competitor}_new.php
   ```

5. **Validate schema**

   - Copy JSON-LD from page
   - Test with Google Rich Results Test

6. **Check performance**

   - Run Lighthouse audit
   - Verify LCP < 2.5s
   - Check CLS < 0.1

7. **Replace old file**

   ```bash
   mv v2/pages/compare_{competitor}_new.php v2/pages/compare_{competitor}.php
   ```

8. **Test on production**
   - Verify page loads correctly
   - Check all images load
   - Test responsive design
   - Verify schema markup

## Reference Files

**New Design Examples:**

- `v2/pages/compare_awork.php`
- `v2/pages/compare_askdante.php`
- `v2/pages/compare_7shifts.php`
- `v2/pages/compare_clockin.php`
- `v2/pages/compare_clockify.php`

**Old Design Examples:**

- `v2/pages/compare_flairhr.php`

**Component Files:**

- `v2/components/ordio_comparison_content.php`
- `v2/base/compare_carousel.php`
- `v2/data/ordio_comparison_data.php`
- `v2/data/tools_data.php`

**CSS:**

- `v2/css/comparison-pages.css`

## Additional Resources

- [Comparison Pages Structure Reference](COMPARISON_PAGES_STRUCTURE.md)
- [Comparison Pages Quick Reference](COMPARISON_PAGES_ai//QUICK_REFERENCE.md)
- [Comparison Pages Guide](COMPARISON_PAGES_GUIDE.md)
