Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+2 votes
in Q2A Core by
I am using an advanced theme to override two functions:

1. function main()

2. function q_view($q_view)

In main() I am also checking some user information, like is logged in and more! Then I set a boolean variable in main().

This boolean variable I need to access now from within q_view(), without doing all the queries again that I did in main().

How would you do that?

Thanks and have a good weekend,
I tried to declare a global variable in advanced theme:

private $globalHelper = false;

and set this in main() to true,
then I tried to read it in q_view(),
which resulted in: "Error: Undefined variable"

2 Answers

+1 vote
edited by
Best answer

All right, here is an example how it is gonna work:

class qa_html_theme extends qa_html_theme_base {

    var $globalHelper = false;

    function main() {

       // default code

        $this->globalHelper = true;


    function q_view($q_view) {

       if ($this->globalHelper ) {

            // ..



} // end class


Note that in $this->globalHelper  $globalHelper has no dollar sign in front anymore!

+1 vote
Please read here:




Would be great if You could post an example if You figure it out finally. I still have problems with this.
Thanks, that helped me! Example with explanation will be posted here in a moment :)