0 WHERE $visible GROUP BY kb_article_category_id, category_name, category_icon, category_order ORDER BY kb_article_category_id = 0, category_order ASC, category_name ASC"); $all_count = 0; while ($row = mysqli_fetch_assoc($sql)) { $categories[intval($row['kb_article_category_id'])] = ['name' => $row['category_name'] ?? 'Other', 'icon' => categoryIcon($row['category_icon'] ?? '') ?: 'book', 'count' => intval($row['n'])]; $all_count += intval($row['n']); } $category = isset($_GET['category']) && isset($categories[intval($_GET['category'])]) ? intval($_GET['category']) : null; $where = $visible . ($category !== null ? " AND kb_article_category_id = $category" : ''); if ($q !== '') { $q_sql = escapeSql($q); $where .= " AND (kb_article_title LIKE '%$q_sql%' OR kb_article_summary LIKE '%$q_sql%' OR MATCH(kb_article_content_raw) AGAINST ('$q_sql'))"; } $total = intval(mysqli_fetch_row(mysqli_query($mysqli, "SELECT COUNT(*) FROM kb_articles WHERE $where"))[0]); // A search of all of Help that found nothing goes on the Knowledge Base's Not found list if ($q !== '' && !$total && $category === null && !portalViewingAs()) { kbSearchMissSave($q, 'portal', $session_client_id); } $pages = max(1, (int) ceil($total / $per_page)); $page = min(max(1, intval($_GET['page'] ?? 1)), $pages); $offset = ($page - 1) * $per_page; // A search puts the closest first; otherwise the newest $order = $q !== '' ? "(kb_article_title LIKE '%$q_sql%') DESC, MATCH(kb_article_content_raw) AGAINST ('$q_sql') DESC" : 'COALESCE(kb_article_updated_at, kb_article_created_at) DESC'; $articles = mysqli_query($mysqli, "SELECT kb_article_id, kb_article_title, kb_article_summary, kb_article_content, kb_article_created_at, kb_article_updated_at, category_name, category_icon FROM kb_articles LEFT JOIN categories ON category_id = kb_article_category_id AND kb_article_category_id > 0 WHERE $where ORDER BY $order, kb_article_title ASC LIMIT $per_page OFFSET $offset"); /** This page's address with some of its settings changed. */ function kbPortalUrl(array $changes) { global $category, $q; $params = array_merge(['category' => $category, 'q' => $q !== '' ? $q : null], $changes); $params = array_filter($params, function ($v) { return $v !== null && $v !== ''; }); return 'kb.php' . ($params ? '?' . http_build_query($params) : ''); } ?>

Help

How-tos and answers from

Ask us
1) { ?>
'articles', 'filtered' => true, 'match_text' => 'No article mentions “' . escapeHtml($q) . '”.', 'clear_url' => kbPortalUrl(['q' => null, 'page' => null]), 'actions' => [['label' => 'Ask us', 'href' => portalAskUrl($q), 'icon' => 'fa-plus']]]) ?> 'Nothing here yet', 'text' => 'How-tos and answers we share with you show here. Ask us anything in the meantime.', 'icon' => 'fa-book', 'filtered' => false, 'actions' => [['label' => 'Ask us', 'href' => 'ticket_add.php', 'icon' => 'fa-plus']]]) ?> 1) { ?>
- of