Question2Answer is a PHP script namenjena dedicated to websites with questions and answers.
Q2A script doesn't have theme/template consisted of HTML file, but rather all outputs are performed though PHP code and functions. However, it is very easy to create your own theme and we'll describe how to do it.
Structure of a Question2Answer theme
Every theme has its own folder in directory /qa-theme. The theme folder consists of:
- qa-styles.css - a file with CSS styles
- images
- and optional the qa-theme.php - contains custom code and HTML outputs
How to create custom Q2A theme
1) Create a copy of a already existing theme (Default or Candy)
2) Change name of new folder as you wish
3) Make changes in qa-styles.css file or replace images. The CSS file contains meta information about your theme (web address, version, author, license...) so you can change them if you want to identify you as the theme creator. This changes also allows Question2Answer script to check for theme updates.
4) Go to Admin panel, select your theme in General section and save the changes
5) If you make any changes they will be visible when you visit your site
qa-theme.php file modification
Purpose of the qa-theme.php file is to override default layout and contains your own modifications. The qa-theme.php contains functions that outputs HTML code (remember that there is not "common" HTML files with layout, but everything is output via PHP code).
1) Create file qa-theme.php in your theme's folder
Note: If your theme uses non English characters, encode the file using UTF-8 encoding without a BOM (byte order mark).
2) Add the following code
<?php
class qa_html_theme extends qa_html_theme_base {
}
3) You can easily find HTML parts to be changed with the View Source in your browser.
4) The qa-theme-base.php file, located in qa-include folder, contains complete logic for displaying HTML code.
Tip: Every logic has its own function that outputs HTML code. For example, function q_view() displays question.
5) If you need to change existing logic, copy appropriate function from the qa-theme.base.php file into your qa-theme.php file and make changes. As an example, you can read this article how to insert Adsense code in Question2Answer script.
Note: Avoid using DOM element IDs, but use classes instead; IDs are reserved for the Q2A control layer.