Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+2 votes
1.3k views
in Plugins by
edited by
So I want create new page, but the documentacion is too hard.

I created "hello" folder in qa-plugin. I created qa-plugin.php file. The content:

<?php

/*
    Plugin Name: Hello
    Plugin URI:
    Plugin Update Check URI:
    Plugin Description: Text.......
    Plugin Version: 0.1
    Plugin Date: 2014-03-05
    Plugin Author: atomjani
    Plugin Author URI:
    Plugin License: GPLv2
    Plugin Minimum Question2Answer Version: 1.6
*/

    if (!defined('QA_VERSION')) { // don't allow this page to be requested directly from browser
        header('Location: ../../');
        exit;
    }

qa_register_plugin_module('page', 'hello.php', 'hello_page', 'Hello Page');

/*
    Omit PHP closing tag to help avoid accidental output
*/

This is ok?

I created the hello.php file. The content:

<?php

    class hello_page {
        
        var $directory;
        var $urltoroot;
        
        function load_module($directory, $urltoroot)
        {
            $this->directory=$directory;
            $this->urltoroot=$urltoroot;
        }
        
        function suggest_requests() // for display in admin interface
        {    
            return array(
                array(
                    'title' => 'Hello',
                    'request' => 'hello_page',
                    'nav' => 'M', // 'M'=main, 'F'=footer, 'B'=before main, 'O'=opposite main, null=none
                ),
            );
        }
        
        function match_request($request)
        {
            if ($request=='hello_page')
                return true;
            return false;
        }
        
        function process_request($request)
        {
            $qa_content=qa_content_prepare();

            $qa_content['title']='This is the browser tittle';
            $qa_content['error']='An example error';
            $qa_content['custom']='Some <b>custom html</b>';

            $qa_content['custom_2']='<p><br>More <i>custom html</i></p>';
            
            return $qa_content;
        }
    
    };
   
/*
    Omit PHP closing tag to help avoid accidental output
*/

First I want to create this page and show it in menu. And if this work, I want to put some php code, sql querry. I didn't know that the cookie or session is working with this, because I want some function for registered user. First I have to understand the QA2 plugin using.
Q2A version: 1.6.x
by
This is not good, I get somme errors:
Warning: session_start() [function.session-start]: Cannot send session cache limiter - headers already sent (output started at /home/pckozoss/public_html/qa-plugin/hello/qa-plugin.php:1) in /home/pckozoss/public_html/qa-include/qa-app-users.php on line 150

Warning: Cannot modify header information - headers already sent by (output started at /home/pckozoss/public_html/qa-plugin/hello/qa-plugin.php:1) in /home/pckozoss/public_html/qa-include/qa-page.php on line 734

Warning: Cannot modify header information - headers already sent by (output started at /home/pckozoss/public_html/qa-plugin/hello/qa-plugin.php:1) in /home/pckozoss/public_html/qa-include/qa-page.php on line 363

2 Answers

+2 votes
by

The q2a distribution contains an example page from which you could start.

You can also see it in the plugins list ( Admin ---> Plugins ).

You can enable it in Admin ---> Pages ---> "Pages available via plugins" ---> "add link"

 

by
If this helped me, I didn't add my question. There is alot of code and I don't understand these. The comments didn't help me.
by
What link should i add? For localhost/question2answer-1.7/index.php?qa=example-page i get "Page not found"
0 votes
by
the plugin work good, but what about more pages?

we need to make plugin for every page or we can use one plugin for meny pages?
...