How to install Sngine Helpcenter

How to Install Sngine Helpcenter

Help Center Module Installation Guide for Sngine

Welcome to the installation guide for the Help Center Module developed by Jane dos Santos from ScriptsTribe.com. This module adds a powerful FAQ and Knowledge Base system to your Sngine website, allowing you to organize help articles into categories and subcategories with ease.

This step-by-step tutorial will walk you through the process of installing and configuring the Help Center on your platform. By the end of this guide, your website will have a fully functional Help Center where users can browse through categories, find answers, and improve their overall experience.

⚠️ Important:

This module is licensed for single-site use only. Redistribution or resale is strictly prohibited. Ensure you have proper backups of your website and database before proceeding.

🔧 What You'll Need:

If you site is  highly customized and you need to install manually Stop here and start from step 6

Fast Install by uploading all files


Step 1: Edit .htaccess and Upload files

Open your .htaccess located at the root directory on your sngine add and save

RewriteRule ^helpcenter/?$ modules/helpcenter.php [L,QSA]

Download the zip and extract to you computer, open helpcenter folder, it should look like this 

files.PNG

Upload all the content of the folder in your site root following the folder structure. 

Step 2: Install the database tables

In this step, 3 tables will be added to your sngine database

  1. helpcenter_categories
  2. helpcenter_subcategories
  3. helpcenter_questions

To do this just follow the installation url at yousite.com/installhelp.php

you should see something like this , just click the install button.

Helpcenter_install.png

Step 3: Clear you cache, Visit your admincp 

That is all, you are done if you choose the full file upload setup.

now just go to your yoursite.com/admincp

you should see the menu like this 

admin.png

Step 4: Adding Content

The FAQ system is designed with a nested accordion structure, meaning that questions must be added to a subcategory for proper organization and display.

To ensure the accordion looks clean and professional, follow these steps:

  1. Add Categories – These serve as the main sections of your Help Center.
  2. Add Subcategories – These are nested under categories and help organize your content further.
  3. Add Questions – When adding a question, you'll need to select the appropriate subcategory it belongs to.

By following this structure, your FAQ will be well-organized and visually appealing for users.

Step 5: Translation?

Currently, the Help Center is translation-ready for Categories, Subcategories, and even the Question titles. However, the translation of Answers is not yet supported.

I’m actively working on a solution to make the Answers fully translatable. Stay tuned for future updates as I continue to improve this feature!

Manual Installation


Step 1: Edit .htaccess and Upload Files

Open your .htaccess located at the root directory on your sngine add and save

# Help Center Main Page
RewriteRule ^helpcenter/?$ modules/helpcenter.php [L,QSA]

 

Download the zip and extract to you computer, open helpcenter folder, it should look like this 

files.PNG


Upload only the file the is not default to sngine, These are:

/content/themes/default/templates/admin.helpcenter.tpl

/content/themes/default/templates/helpcenter.tpl

/content/themes/default/templates/helpcenter_categories.recursive_rows.tpl

/content/themes/default/templates/latestfaq.tpl

/includes/ajax/admin/helpcenter.php

/modules/helpcenter.php

/installhelp.php

Step 2: Install the database tables

In this step, 3 tables will be added to your sngine database

  1. helpcenter_categories
  2. helpcenter_subcategories
  3. helpcenter_questions

To do this just follow the installation url at yousite.com/installhelp.php

you should see something like this , just click the install button.

Helpcenter_install.png

Step 3: Lets Edit the files 

Permission to visit admin area: Open /admin.php (The one in the root folder) 

Look for 

case 'blogs':

and before that add and save:

 //HELPCENTER START 
		 case 'helpcenter':
    // Check admin or moderator
    if (!$user->_is_admin && !$user->_is_moderator) {
        _error(403);
    }
    page_header($control_panel['title'] . " › " . __("Help Center"));
    $sub_view = $_GET['sub_view'] ?? 'categories';

    switch ($sub_view) {
        // 1) categories
        case 'categories':
            // fetch all categories (with or without recursion)
            $rows = [];
            $get = $db->query("SELECT * FROM helpcenter_categories ORDER BY category_order ASC") or _error("SQL_ERROR");
            while ($row = $get->fetch_assoc()) {
                $rows[] = $row;
            }
            $smarty->assign('rows', $rows);
            break;

        case 'add_category':
        case 'edit_category':
            if ($sub_view == 'edit_category' && isset($_GET['id'])) {
                $id = (int)$_GET['id'];
                $get_data = $db->query("SELECT * FROM helpcenter_categories WHERE id=$id") or _error("SQL_ERROR");
                if ($get_data->num_rows) {
                    $cat = $get_data->fetch_assoc();
                    $smarty->assign('data', [
                        'id' => $cat['id'],
                        'category_name' => $cat['name'],
                        'category_description' => $cat['description'],
                        'category_order' => $cat['category_order']
                    ]);
                }
            }
            // optionally fetch $all_categories if you want a parent dropdown
            break;
			
	


        // 2) subcategories
        case 'subcategories':
            // get all subcategories + parent category name
            $rows = [];
            $get_subs = $db->query("
              SELECT sc.*, c.name as parent_name
              FROM helpcenter_subcategories sc
              LEFT JOIN helpcenter_categories c ON sc.category_id = c.id
              ORDER BY sc.id ASC
            ") or _error("SQL_ERROR");
            while ($sub = $get_subs->fetch_assoc()) {
                $rows[] = $sub;
            }
            $smarty->assign('rows', $rows);
            break;

        case 'add_subcategory':
        case 'edit_subcategory':
            // if editing
            if ($sub_view == 'edit_subcategory' && isset($_GET['id'])) {
                $id = (int)$_GET['id'];
                $res = $db->query("SELECT * FROM helpcenter_subcategories WHERE id=$id") or _error("SQL_ERROR");
                if ($res->num_rows) {
                    $subcat = $res->fetch_assoc();
                    $smarty->assign('data', [
                        'id' => $subcat['id'],
                        'subcategory_name' => $subcat['name'],
                        'subcategory_description' => $subcat['description'],
                        'category_id' => $subcat['category_id']
                    ]);
                }
            }
            // fetch all categories for the <select>
            $cats = [];
            $get_cats = $db->query("SELECT id, name FROM helpcenter_categories ORDER BY category_order ASC") or _error("SQL_ERROR");
            while ($cat = $get_cats->fetch_assoc()) {
                $cats[] = $cat;
            }
            $smarty->assign('categories', $cats);
            break;

        // 3) questions
        case 'questions':
            $rows = [];
            $get_q = $db->query("
              SELECT q.*, sc.name as subcategory_name
              FROM helpcenter_questions q
              LEFT JOIN helpcenter_subcategories sc ON q.subcategory_id = sc.id
              ORDER BY q.id ASC
            ") or _error("SQL_ERROR");
            while ($row = $get_q->fetch_assoc()) {
                $rows[] = $row;
            }
            $smarty->assign('rows', $rows);
            break;

        case 'add_question':
        case 'edit_question':
            if ($sub_view == 'edit_question' && isset($_GET['id'])) {
                $id = (int)$_GET['id'];
                $resQ = $db->query("SELECT * FROM helpcenter_questions WHERE id=$id") or _error("SQL_ERROR");
                if ($resQ->num_rows) {
                    $qrow = $resQ->fetch_assoc();
                    $smarty->assign('question', [
                        'id' => $qrow['id'],
                        'question' => $qrow['question'],
                        'answer' => $qrow['answer'],
						'category_id' => $qrow['category_id'],
                        'subcategory_id' => $qrow['subcategory_id']
                    ]);
                }
            }
            // fetch subcategories for the dropdown
            $subList = [];
            $get_sc = $db->query("SELECT id, name FROM helpcenter_subcategories ORDER BY id ASC") or _error("SQL_ERROR");
            while ($s = $get_sc->fetch_assoc()) {
                $subList[] = $s;
            }
            $smarty->assign('subcategories', $subList);
            break;

        default:
            $sub_view = 'categories';
            // similar to case 'categories' above
            // ...
            break;
    }
		  
    // final
    $smarty->assign('sub_view', $sub_view);
   
    break;
 //HELPCENTER END

Adding the admin Menus: Open /content/themes/default/templates/admin.tpl

Look for 

<!-- Modules -->
      <div class="card mb15">
        <div class="card-header block-title">
          {__("Modules")}
        </div>
        <div class="card-body with-nav">
          <ul class="side-nav">

and after that add 

<li {if $view == "helpcenter"}class="active" {/if}>
              <a href="#helpcenter" data-bs-toggle="collapse" {if $view == "helpcenter"}aria-expanded="true" {/if}>
                <i class="fa fa-newspaper fa-lg fa-fw mr10" style="color: #F44336"></i>{__("Helpcenter")}
              </a>
              <div class='collapse {if $view == "helpcenter"}show{/if}' id="helpcenter">
                <ul>
                  <li {if $view == "helpcenter" && $sub_view == ""}class="active" {/if}>
                    <a href="{$system['system_url']}/{$control_panel['url']}/helpcenter/questions">
                      {__("Add Questions")}
                    </a>
                  </li>
                  <li {if $view == "helpcenter" && $sub_view == "pending"}class="active" {/if}>
                    <a href="{$system['system_url']}/{$control_panel['url']}/helpcenter/categories">
                      {__("Add Categories")}
                    </a>
                  </li>
                  <li {if $view == "helpcenter" && $sub_view == "subcategories"}class="active" {/if}>
                    <a href="{$system['system_url']}/{$control_panel['url']}/helpcenter/subcategories">
                      {__("Add Subcategories ")}
                    </a>
                  </li>
                </ul>
              </div>
            </li>

Add Ajax functionality: Open /includes/assets/js/core/admin.js

Look for 

api['admin/reset'] = ajax_path + "admin/reset.php";

After that add

// HELPCENTER START
api['admin/helpcenter'] = ajax_path + "admin/helpcenter.php";

$(document).on('change', '#category-select', function () {
    const categoryId = $(this).val();
    const subcategorySelect = $('#subcategory-select');
    // Clear existing options
    subcategorySelect.empty().append('<option value="" disabled selected>Select Subcategory</option>');

    // Fetch subcategories dynamically
    $.ajax({
        url: 'admin/helpcenter.php',
        type: 'POST',
        data: { do: 'get_subcategories', category_id: categoryId },
        dataType: 'json',
        success: function (response) {
            if (response.success) {
                response.subcategories.forEach(function (subcategory) {
                    subcategorySelect.append(
                        `<option value="${subcategory.id}">${subcategory.name}</option>`
                    );
                });
            } else {
                alert(response.message);
            }
        },
        error: function () {
            alert('Failed to load subcategories. Please try again.');
        },
    });
});

$(document).on('submit', '.js_ajax-forms', function (e) {
    e.preventDefault();
    let form = $(this);
    let action = form.find('input[name="do"]').val(); // Get the action from the hidden input
    let url = form.data('url');
    let submitButton = form.find('button[type="submit"]');

    submitButton.prop('disabled', true);
    form.find('.alert').addClass('x-hidden').text('');

    $.ajax({
    type: "POST",
    url: url,
    data: form.serialize(),
    dataType: "json",
    beforeSend: function () {
        submitButton.prop('disabled', true).text('Processing...');
    },
    success: function (response) {
        submitButton.prop('disabled', false).text('Save Changes');
        if (response.success) {
            form.find('.alert-success').removeClass('x-hidden').text(response.message);
            if (response.callback) {
                window.location.href = response.callback;
            }
        } else {
            form.find('.alert-danger').removeClass('x-hidden').text(response.message);
        }
    },
    error: function (xhr) {
        submitButton.prop('disabled', false).text('Save Changes');
        form.find('.alert-danger').removeClass('x-hidden').text("Something went wrong. Please try again.");
    }
});


$('body').on('click', '.js_admin-deleter', function () {
    let handle = $(this).data('handle');
    let id = $(this).data('id');
    confirm(__['Delete'], __['Are you sure you want to delete this?'], function () {
        $.post(api['admin/helpcenter'], { do: 'delete', handle: handle, id: id }, function (response) {
            if (response.callback) {
                eval(response.callback);
            } else {
                window.location.reload();
            }
        }, 'json').fail(function () {
            modal('#modal-message', { title: __['Error'], message: __['Something went wrong!'] });
        });
    });
});
// HELPCENTER END

Adding deletion ability: Open /includes/ajax/admin/delete.php

look for 

 /* delete post */
      $user->delete_post($_POST['id'], false);
      break;

After that add 


		  case 'helpcenter_category':
    if (!$user->_is_admin && !$user->_is_moderator) {
        modal("MESSAGE", __("System Message"), __("You don't have the right permission to access this"));
    }

    // Delete all questions related to this category
    $db->query(sprintf(
        "DELETE FROM helpcenter_questions WHERE subcategory_id IN (SELECT id FROM helpcenter_subcategories WHERE category_id = %s)",
        secure($_POST['id'], 'int')
    )) or _error("SQL_ERROR");

    // Delete all subcategories under this category
    $db->query(sprintf(
        "DELETE FROM helpcenter_subcategories WHERE category_id = %s",
        secure($_POST['id'], 'int')
    )) or _error("SQL_ERROR");

    // Delete the category
    $db->query(sprintf(
        "DELETE FROM helpcenter_categories WHERE id = %s",
        secure($_POST['id'], 'int')
    )) or _error("SQL_ERROR");

    break;

case 'helpcenter_subcategory':
    if (!$user->_is_admin && !$user->_is_moderator) {
        modal("MESSAGE", __("System Message"), __("You don't have the right permission to access this"));
    }

    // Delete all questions under this subcategory
    $db->query(sprintf(
        "DELETE FROM helpcenter_questions WHERE subcategory_id = %s",
        secure($_POST['id'], 'int')
    )) or _error("SQL_ERROR");

    // Delete the subcategory
    $db->query(sprintf(
        "DELETE FROM helpcenter_subcategories WHERE id = %s",
        secure($_POST['id'], 'int')
    )) or _error("SQL_ERROR");

    break;

case 'helpcenter_question':
    if (!$user->_is_admin && !$user->_is_moderator) {
        modal("MESSAGE", __("System Message"), __("You don't have the right permission to access this"));
    }

    // Delete the question
    $db->query(sprintf(
        "DELETE FROM helpcenter_questions WHERE id = %s",
        secure($_POST['id'], 'int')
    )) or _error("SQL_ERROR");

    break;

Step 4: Clear you cache, Visit your admincp 

That is all, you are done if you choose the full file upload setup.

now just go to your yoursite.com/admincp

you should see the menu like this 

admin.png

Step 5: Adding Content

The FAQ system is designed with a nested accordion structure, meaning that questions must be added to a subcategory for proper organization and display.

To ensure the accordion looks clean and professional, follow these steps:

  1. Add Categories – These serve as the main sections of your Help Center.
  2. Add Subcategories – These are nested under categories and help organize your content further.
  3. Add Questions – When adding a question, you'll need to select the appropriate subcategory it belongs to.

By following this structure, your FAQ will be well-organized and visually appealing for users.

Step 5: Translation?

Currently, the Help Center is translation-ready for Categories, Subcategories, and even the Question titles. However, the translation of Answers is not yet supported.

I’m actively working on a solution to make the Answers fully translatable. Stay tuned for future updates as I continue to improve this feature!