Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+4 votes
1.8k views
in Q2A Core by
Hi,

I want to add "frequent asked questions" and terms / privacy".

what pages I need to editing?

Thanks

2 Answers

0 votes
by
To do this the easiest way, here are the steps for a FAQs page:

1. Add a navigation element within the big array in qa_content_prepare() in qa-index.php. For example, you could change the footer:

'footer' => array(
    'feedback' => array(
        'url' => qa_path_html('feedback'),
        'label' => qa_lang_html('main/nav_feedback'),
    ),
),

... to ...

'footer' => array(
    'feedback' => array(
        'url' => qa_path_html('feedback'),
        'label' => qa_lang_html('main/nav_feedback'),
    ),

    'faqs' => array(
        'url' => qa_path_html('faqs'),
        'label' => 'FAQs',
    ),
),

(Up to this point, you will have the navigation link on all pages, but when you navigate to the FAQs page, you will be given the 'Page not found' error. The next steps are to show what you want instead of that error.)

2. In qa-index.php, replace the following line:

$qa_template='not-found';

... with ...

$qa_template=$qa_request_lc;

(This will allow the theme to see a request was made for the FAQs page.)

3. Create an advanced custom theme by following the instructions here: http://www.question2answer.org/advanced.php#theme-advanced

4. In your theme's qa-theme.php file, override the main() method to show something different for the FAQs request by using code like this below:

<?php

    class qa_html_theme extends qa_html_theme_base
    {
        function main()
        {
            if ($this->template=='faqs') {
                // output the content of your FAQS page...

            } else
                qa_html_theme_base::main();
        }
    }
   
?>

You can extend according to the same principle for other pages.

And of course it is planned that Question2Answer will include the ability to define your custom pages in future in a less complicated way!
by
Actually, instead of step 1 above, you can modify the navigation list within your theme file. You would add something like this into qa-theme.php, within the class definition for qa_html_theme:

        function nav_list($navigation, $navtype)
        {
            if ($navtype=='footer')
                $navigation['faqs']=array( 'url' => qa_path_html('faqs'), 'label' => 'FAQs');
           
            qa_html_theme_base::nav_list($navigation, $navtype);
        }

The advantage of this method is that you made fewer modifications to the main Q2A files, so you can update to future versions more easily. Also, the change in step 2 above will be integrated into the main source code for the 1.0 release. At that point, your changes will be in the theme only.
asked Apr 3, 2010 in Q2A Core by anonymous How to add title and content?
by
Actually on closer consideration the version 1.0 release will not include the change described in step 1 above. So the $this->template will still be 'not-found' for your custom page. However there will be a new value you can check inside your theme class, $this->request, which will contain the original request, so you can check if ($this->request=='faqs') instead in step 4 above.
+1 vote
by
I think he wanted to find a way to add a new page. I was looking for answer to the same question, but didn't find any. I finally found the way to do it:

Edit your qa-index.php page, under "$qa_routing=array(..."
add a new definition such as:
'glossary' => QA_INCLUDE_DIR.'qa-page-glossary.php',

And create a new php file for 'qa-page-glossary.php'

http://interviews.jbasket.com/
...