Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+5 votes
1.4k views
in Plugins by
Hi, I want to add a custom page in my q2a-page, this page should contains HTML and PHP-code. I know there is the possibility to code a page-plugin, but I need an example on how to do it. The page with the tutorial lacks a lot of information, could someone provide a simple example for this. Thx.
Q2A version: 1.5.4

1 Answer

+2 votes
by
1. Simplest example
You can add page by general making method of HTML or PHP.
  1. Create hello.php
  2. Edit hello.php (contents: echo 'Hello world!';)
  3. Upload hello.php to folder that you want.

2. Example to use Q2A framework

  1. Create hello.php
  2. Edit hello.php (*see below)
  3. Upload hello.php to Q2A root (in this case).
<?php
require_once './qa-include/qa-base.php';  // Check path
require_once QA_INCLUDE_DIR.'qa-db-selects.php';  // You can various database access function
require_once QA_INCLUDE_DIR.'qa-app-options.php';  // You can view qa_options table value
require_once QA_INCLUDE_DIR.'qa-app-format.php';   // You can use various functions
require_once QA_INCLUDE_DIR.'qa-util-string.php';  // You can use string utility functions
...
echo 'Hello world!';
/*
Omit PHP closing tag to help avoid accidental output
*/

 

by
ok, but I want my page to look like the q2apage with header, footerm, sidebar...
by
edited by
If you expect various parts output of page to Q2A core, it is wise to use page plugin. If you dislike page plugin when you make PHP page, I think that it is necessary to remodel Q2A admin -> page feature. For example, $custompage '[content]' is analyzed by eval() in lower program.

qa-include/qa-page-default.php (about L75? [case V1.6])
$qa_content['custom']=$custompage['content']

Because this is not comply with Q2A manners, you must carry out this method with your risk. I hope that Q2A page feature will support PHP in the future. However, it isn't supported yet. This resembles the flow that  WordPress strengthened static page little by little.
...