Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+1 vote
in Q2A Core by
I am trying to access an image that is located inside the plugin directory. How do I do it from the Theme layer that I have registered in this plugin?

Q2A version: 1.6

2 Answers

+3 votes
selected by
Best answer

in themes:

$theme_dir = dirname( __FILE__ ) . '/';
$theme_url = qa_opt('site_url') . 'qa-theme/' . qa_get_site_theme() . '/';
example: qa-theme.php
in other Layers add this variables and function to your layer:
var $plugin_directory;
var $plugin_url;
function qa_html_theme_layer($template, $content, $rooturl, $request)
global $qa_layers;
$this->plugin_directory = $qa_layers['Webmaster Layer']['directory'];
$this->plugin_url = $qa_layers['Webmaster Layer']['urltoroot'];
qa_html_theme_base::qa_html_theme_base($template, $content, $rooturl, $request);
Thanks for your answer. Really appreciate.
Note that it does not work if the user has not friendly URLs enabled under admin/general. See details here: https://github.com/q2a/question2answer/issues/122
Using "function qa_html_theme_layer()" will cause the PHP WARNING: "PHP Deprecated:  Methods with the same name as their class will not be constructors in a future version of PHP; layer_php has a deprecated constructor in \qa-include\qa-base.php(595) : eval()'d code on line 18". Use "QA_HTML_THEME_LAYER_URLTOROOT" instead.
+1 vote
edited by

Within the layer you can use the constant:


as described in the docs: http://www.question2answer.org/layers.php

With the qa-theme.php you can use: