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 want to make a page and add a javascript source after a div element. my code is like this:

public function process_request($request)
		$qa_content = qa_content_prepare();

		$qa_content['title'] = qa_lang_html('example_page/page_title');
		$qa_content['error'] = 'An example error';
		$qa_content['custom'] = '<div>custom html</div>';

		$qa_content['script'] = '<script type="text/javascript" src="'.$this->directory.'myscript.js"></script>';

		return $qa_content;

But it doesn't work.

Q2A version: 1.8.3

1 Answer

+2 votes
selected by
Best answer

Just add the below code

var $directory;

var $urltoroot;

function load_module($directory, $urltoroot)






Replace $this->directory with __DIR__ 

Thank you Arjunsuresh. Is it true to use $qa_content['script']? or it must be $qa_content['custom']?
You're adding as a html and so it should be under custom. The current code is actually blocking all other scripts as you are overriding the script variable. If you have another custom html, you must add under custom_2 and so on.