Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+1 vote
412 views
in Q2A Core by
I noticed that I can call some QA functions from within an advanced theme (qa-theme.php), while for others you need to include the correct functions file.

For example, I am able to call qa_get_logged_in_level() in the qa-theme.php if I'm on the user page ($this->template=='user') and qa_db_user_account_selectspec() if I'm on any page on the website. I can call these functions without including any other files.

How does one know which functions you need to include the functions file and which functions are available for immediate use in the qa-theme.php? Does the qa-theme.php automatically inherit all the functions for a specific page if its on that page? Is there a list of global functions?
by
As a further example: If I'm on a questions list page for a category, can I just call the qa_db_category_nav_selectspec() function in the appropriate part of the qa-theme.php to get information about the category, or do I need to first have the: require_once QA_INCLUDE_DIR.'qa-db-selects.php';  in my qa-theme.php in that part of the qa-theme.php where I can the function?

1 Answer

+1 vote
by

You have to check which files are included in which page.  Look at the qa-page-*.php files and see what they include.  For example, qa-page-question.php has the following:

    require_once QA_INCLUDE_DIR.'qa-app-cookies.php';
    require_once QA_INCLUDE_DIR.'qa-app-format.php';
    require_once QA_INCLUDE_DIR.'qa-db-selects.php';
    require_once QA_INCLUDE_DIR.'qa-util-sort.php';
    require_once QA_INCLUDE_DIR.'qa-util-string.php';
    require_once QA_INCLUDE_DIR.'qa-app-captcha.php';
    require_once QA_INCLUDE_DIR.'qa-page-question-view.php';
    require_once QA_INCLUDE_DIR.'qa-app-updates.php';

You can always just use require_once anyway, since if it is already included it will not include it again.

...