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

We all know that all the html code is written out by qa-theme-base.php. It is very difficult to modify the HTML code in this way. At the same time it is very difficult to understand the logic that transfer the $qa_content to pure HTML code.

In this function:

function output_array($elements)

I can get the HTML code of every page. I can create a new PHP file and paste these HTML code to this file. At the qa-page.php I didn't call qa_output_content function. Instead I used require_once to include the new created file. The at the new file I can use <?php echo $qa_content['...']; ?> to show the correct content. In my experience it worked well.

I want to know the advantage and disadvantage of this method. And why question2answer didn't use this method too?

Q2A version: 1.5.2
by
This is my biggest complaint with the Q2A design. A template system should have been used for page layout.

2 Answers

0 votes
by
Q2A uses overriding functions in theme-base class. you can change the layer as you need. but unfortunately this class does not access to core.
so main problem with Q2A themes isn't the layer, problem is that you can't directly access core functions to create flexible themes. for example if you want to get category list for any reason you have to get them directly from DB, or if you want to load SubNav for every MainNav Item to show it as a menu you will have a hard time.
it is not hard, since most functions already exist. but it is not efficient either.
+2 votes
by
I understand where you're coming from and I am always debating this.

The reason behind Q2A's current design is to allow themes or plugins (via layers) to modify small parts of the page, by overriding the appropriate theme functions. This allows multiple plugins to modify different parts of the page, without interfering with each other. It wouldn't be possible with a template-centered architecture.

On the other hand it makes it harder for non-programmers to make small modifications to the HTML for their pages, and I understand it's a problem.

I think the long term solution is to allow people to choose whether to use templates or not, perhaps on a per-page basis. But this will be a major architectural change and would only appear in a major new version ("Q2A 2.0"?)
...