📐 Blueprint & Prompt Generator Tema CMS

Dokumentasi teknis ketat untuk pembuatan tema. Dibuat agar AI tidak meleset dalam generate kode.

⚠️ PERHATIAN UNTUK AI: Saat menggunakan prompt di bagian bawah halaman ini, AI WAJIB mengikuti struktur variabel, array, dan fungsi persis seperti yang didokumentasikan di bawah. Dilarang mengubah nama variabel atau membuat fungsi database sendiri.

1. Injeksi Variabel Global oleh Core System

File index.php (Front Controller) telah menyiapkan variabel berikut sebelum memuat file tema. Gunakan langsung tanpa query database:

2. Fungsi Helper Wajib

AI harus menggunakan fungsi ini untuk mengambil data dinamis:

// Mengambil menu navigasi
get_menus('header'); // return array of ['title', 'url']
get_menus('footer'); 

// Mengambil daftar post terbaru (untuk sidebar/loop)
get_posts('article', 5, 0); // get_posts($type, $limit, $offset)

// Generate URL sesuai pengaturan permalink admin
generate_url($post['slug'], $post['type'], $settings); // WAJIB dipakai untuk link

3. Aturan Warna (CSS Variables)

Warna TIDAK BOLEH di-hardcode. File header.php WAJIB menginjeksi warna dari setting ke CSS :root seperti ini:

<style>
:root {
    --color-primary: <?= htmlspecialchars($settings['color_primary'] ?? '#4F46E5') ?>;
    --color-secondary: <?= htmlspecialchars($settings['color_secondary'] ?? '#10B981') ?>;
    --color-bg: <?= htmlspecialchars($settings['color_background'] ?? '#F3F4F6') ?>;
    --color-text: <?= htmlspecialchars($settings['color_text'] ?? '#1F2937') ?>;
}
body { background: var(--color-bg); color: var(--color-text); }
.btn { background: var(--color-primary); }
</style>

4. Logika Homepage Builder (index.php)

File index.php tema harus melakukan loop $layout. Jika block pertama adalah full_html, maka echo dan exit (abaikan header/footer).

if (!empty($layout) && $layout[0]['type'] === 'full_html') {
    echo $layout[0]['content'];
    exit;
}
include 'header.php';
foreach ($layout as $block) {
    if ($block['type'] == 'full_html') echo $block['content'];
    elseif ($block['type'] == 'html') echo '<div>'.$block['content'].'</div>';
    elseif ($block['type'] == 'hero') {
        // Akses: $block['title'], $block['desc'], $block['btn_text'], $block['btn_url'], $block['bg_color']
    }
    elseif ($block['type'] == 'image') {
        // Akses: $block['url'], $block['link']
    }
    elseif ($block['type'] == 'divider') {
        // Akses: $block['height']
    }
    elseif ($block['type'] == 'articles') {
        // Akses: $block['title'], $block['limit']
        $articles = get_posts('article', $block['limit'] ?? 3, 0);
        // Loop $articles...
    }
    elseif ($block['type'] == 'products') {
        // Akses: $block['title'], $block['limit']
        $products = get_posts('product', $block['limit'] ?? 4, 0);
        // Loop $products...
    }
}
include 'footer.php';

5. Logika Page.php (Full HTML Deteksi)

$is_full_html = (stripos(trim($post['content']), '<!DOCTYPE') === 0);
if ($is_full_html) {
    echo $post['content'];
    exit;
}
// Lanjut load header.php jika bukan full html

🤖 Master Prompt Generator

Instruksi: Edit spesifikasi desain di dalam kurung siku [...] pada textarea di bawah, lalu copy dan tempel ke AI (Gemini/ChatGPT/Claude).