Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+5 votes
in Q2A Core by
Would it be possible to allow for PHP in addition to HTML in the custom layout pages?  This may seem a little odd, but there are small scripts/unique routines that I may like to add to a page unrelated to the QA script itself.



3 Answers

+3 votes

It's an interesting idea, but for now I suggest you do this using an advanced theme, which allows you to run any PHP code at any point on the page.

Or you can modify qa-page.php wherever it calls output_raw(...) in the theme object. You can make use of PHP's eval(...) function to run the PHP which was stored in the appropriate option setting.

You could also create your own page plugin, right?
Page modules/plugins are for creating an entirely new type of page in Q2A, rather than changing something that applies to all pages.
Yes you're right, I didn't read the question properly :/
+2 votes

The way I got around it was by loading the php into a div inside the custom html  with jquery's .load() ... for example...

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8.1/jquery.min.js"></script>

 $(document).ready(function() {

<div id="test_container"></div>


...it worked fine for me

+1 vote

This is an update of the answer provided by gidgreen, for q2a 1.7.4.

using an advanced theme, you can override output_raw() this way :

    public function output_raw($html)
        if (strlen($html)) {
            $html = eval('?>'.$html.'<?php ');
            echo str_repeat("\t", max(0, $this->indent)).$html."\n";