0) { $_children = get_subtopics($_rootTopicId); if (!empty($_children)) $topics = $_children; } unset($_rootTopicId, $_children); $allTags = audience_tags_enabled() ? get_tags() : []; // Filters from query string $filterTopic = (int)($_GET['topic'] ?? 0); $filterTag = audience_tags_enabled() ? (int)($_GET['tag'] ?? 0) : 0; $filterQ = trim($_GET['q'] ?? ''); // Build documents query with all active filters $where = ["d.status = 'published'"]; $params = []; if ($filterTopic) { $where[] = 'd.topic_id = ?'; $params[] = $filterTopic; } if ($filterQ) { if (fts5_available()) { $where[] = "d.id IN (SELECT document_id FROM search_index WHERE search_index MATCH ? AND status = 'published')"; $params[] = fts5_query($filterQ); } else { $where[] = "(d.title LIKE ? OR d.meta_description LIKE ?)"; $params[] = "%$filterQ%"; $params[] = "%$filterQ%"; } } if ($filterTag) { $where[] = 'd.id IN (SELECT document_id FROM document_tags WHERE tag_id = ?)'; $params[] = $filterTag; } $sql = "SELECT d.*, t.slug AS topic_slug, t.title AS topic_title FROM documents d JOIN topics t ON d.topic_id = t.id WHERE " . implode(' AND ', $where) . " ORDER BY d.updated_at DESC LIMIT 120"; $stmt = db()->prepare($sql); $stmt->execute($params); $recent = $stmt->fetchAll(); $meta = build_meta(); include ROOT_PATH . '/includes/header.php'; ?>
No topics yet. Log in to add one.