Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+3 votes
1.9k views
in Q2A Core by
I would like to make a custom page for my question site. I would like to have a new tab for this page, can anyone tell me how to do this?

5 Answers

+3 votes
by
Check out the answer to this question, it should help:

http://www.question2answer.org/qa/704/how-can-we-add-one-more-tab
+1 vote
by
Ok I tried all that and its not working for me, So I must have done something wrong...

I made a new "qa-theme-base.php" for the new theme folder, and I guess it isn't reading it...
by
Try to change the file name under new theme folder from qa-theme-base.php to qa-theme.php.
Reference:http://www.question2answer.org/advanced.php
"Creating an advanced theme for Question2Answer" 4
by
THANK YOU! that totally worked :D
0 votes
by
how about adding a page though? I got my tab in, now would like to create a page to go with that tab :D
by
See step 4 here: http://www.question2answer.org/qa/450/how-to-add-custom-pages#451

(FYI version 1.1 will handle both aspects of this in a much easier way)
by
Ok I already have a qa-theme.php in my new theme folder, and now I need to figure out how to put the code in correctly with the one code already in it for the tab, how does that work?
by
You can combine them like this:

<?php

    class qa_html_theme extends qa_html_theme_base
    {

        function main()
        {
            if ($this->template=='your-label') {
                // output the content of your page...

            } else
                qa_html_theme_base::main();
        }

        function nav_list($navigation, $navtype)
        {
            if ($navtype=='main')
                $navigation['custom']=array( 'url' => 'http://your-page/', 'label' => 'your-label');
            
            qa_html_theme_base::nav_list($navigation, $navtype);
        }

    }
    
?>
+2 votes
by
edited by
My hack sample to add StaticPages(not ExternalLink) for only V1.0.1. This is a medley of the information that dispersed (Thanks gidgreen and other users). Below sample is FAQ-page.

------------------------------------------------------------------------
【Step1】
File: qa-include/qa-index.php
Operation: Add line(near L507).
------------------------------------------------------------------------
    $qa_routing=array(
          ...
          ...
            'faq' => QA_INCLUDE_DIR.'qa-page-faq.php', /*** add ***/
         );
------------------------------------------------------------------------
【Step2】
File: qa-theme/YourTheme/qa-theme.php
Operation: Make new file. Or add lines( For custom pages[START] ... For custom pages[END]).
------------------------------------------------------------------------
<?php
    class qa_html_theme extends qa_html_theme_base
    {
        /***  For custom pages [START] ***/
        function main()
        {
            $content=$this->content;
            $this->output('<DIV CLASS="qa-main'.(@$this->content['hidden'] ? ' qa-main-hidden' : '').'">');
            $this->page_title(@$this->content['title']);
            $this->page_error();
            switch ($this->template) {
                case 'question':
                    $this->question_main();
                    break;
                case 'tags':
                    $this->top_tags();
                    break;
                case 'users':
                case 'admin/users';
                    $this->top_users();
                    break;
                default:
                    $this->form(@$content['form']);
                    $this->form(@$content['form_2']);
                    $this->q_list_and_form(@$content['q_list']);
                    $this->q_list_and_form(@$content['a_list']);
                    /*** add [start] ***/
                    if (!empty($content['customcontents']))
                        $this->output($content['customcontents'], '');
                    /*** add [end]***/
                    break;
            }
            $this->page_links();
            $this->suggest_next();
            $this->output('</DIV> <!-- END qa-main -->', '');
        }
        function nav_list($navigation, $navtype)
        {
            /*** add [start]***/
            // if ($navtype=='main') // Display to main navigation.
            if ($navtype=='user')  // Display to sub(right-upper) navigation.
                $navigation['faq']=array( 'url' => $options['site_url'] . 'faq', 'label' => 'FAQ');
            /*** add [end]***/
            qa_html_theme_base::nav_list($navigation, $navtype);
        }
        /*** For custom pages [END] ***/
    }
/*
    Omit PHP closing tag to help avoid accidental output
*/
------------------------------------------------------------------------
【Step3】
File: qa-include/qa-page-faq.php
Operation: Make new file.
------------------------------------------------------------------------
<?php
    if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
        header('Location: ../');
        exit;
    }
    // Prepare content for theme
    qa_content_prepare();
   
    $qa_content['title']='FAQ';
    $qa_content['customcontents']='
        /* favorite HTML statement [START] */
        <H2>SubTitle1</H2>
        <P>Detail of SubTitle1(line 1)<BR>Detail of SubTitle1(line 2)</P>
        <H2>SubTitle2</H2>
        <P>Detail of SubTitle2(line 1)<BR>Detail of SubTitle2(line 2)</P>
        <H2>SubTitle3</H2>
        <P>Detail of SubTitle3(line 1)<BR>Detail of SubTitle3(line 2)</P>
        /* favorite HTML statement [END] */
    ';
/*
    Omit PHP closing tag to help avoid accidental output
*/
by
Thanks that totally worked :D
by
However, I can't figure out where to put my content on the page, any idea how to do that?
0 votes
by
Ok this is my page

http://blabandblurt.info/index.php?qa=about

I cannot for the life of me, get content on this page lol.
...