annotate(array( 'attachment_count'=>SqlAggregate::COUNT('attachments'), 'topic_count'=>SqlAggregate::COUNT('topics') )) ->order_by('question'); if ($_REQUEST['cid']) $faqs->filter(array('category_id'=>$_REQUEST['cid'])); if ($_REQUEST['topicId']) $faqs->filter(array('topics__topic_id'=>$_REQUEST['topicId'])); if ($_REQUEST['q']) $faqs->filter(Q::ANY(array( 'question__contains'=>$_REQUEST['q'], 'answer__contains'=>$_REQUEST['q'], 'keywords__contains'=>$_REQUEST['q'], 'category__name__contains'=>$_REQUEST['q'], 'category__description__contains'=>$_REQUEST['q'], ))); echo "
".__('Search Results')."
"; if ($faqs->exists(true)) { echo '
    '; foreach ($faqs as $F) { echo sprintf( '
  1. %s - %s
  2. ', $F->getId(), $F->getLocalQuestion(), $F->getVisibilityDescription()); } echo '
'; } else { echo ''.__('The search did not match any FAQs.').''; } } else { //Category Listing. $categories = Category::objects() ->annotate(array('faq_count'=>SqlAggregate::COUNT('faqs'))) ->filter(array('category_pid__isnull' => true)); if (count($categories)) { $categories->sort(function($a) { return $a->getLocalName(); }); echo '
'.__('Click on the category to browse FAQs or manage its existing FAQs.').'
'; } else { echo __('NO FAQs found'); } } ?>