Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+1 vote
507 views
in Q2A Core by
edited by

With NoahY quick response, I was able to develop the plugin. Check it at https://github.com/bahar/qa_text_before_ask and let me know your feedback.

 

I have setup Q2A for our company support desk. Its working great.

Most of the users are not tech savyy and are posting same questions often. I was looking for a hack/plugin to show some guideline, procedure when user wants to ask a question (before redirecting user to the question asking page).

Like the one available in http://stackoverflow.com/questions/ask

 

I am good at PHP, but very new to Q2A. If some can give me some pointers on implementing this as a plugin, it will be great.

 

Sure, I will share the plugin.

 

Thanks,

Q2A version: 1.4.3

1 Answer

0 votes
by
Welcome :)

I think a widget would accomplish this on a basic level:

http://www.question2answer.org/modules.php#widget

You can use the bundled activity-count-widget as a template, then just use the following to show only on the ask form:

        function allow_template($template)
        {
            return $template=='ask';
        }

To get the widget to change according to the focused element, as in SO, just use the jQuery .focus(), I think.
by
Thanks a lot for your pointers :)

It took around 5 hours to complete it. I guess next plugin will take less time :D

Will you please check the plugin at https://github.com/bahar/qa_text_before_ask

The live demo is available at http://thesixdegree.com/support/ask
by
Looks great :) I don't see this on Stackoverflow, though... anyway, nice concept.  One thing I would recommend is turning it off for people who aren't logged in; seems silly to have people agree to a bunch of conditions for posting only to find out they can't post at all... something like:

if(qa_loggedin_userid()) {
  // show the text
}
by
Good idea. I will.
by
Since I did not had the matter with me, I checked disable showing message box. After that I added the contents and unchecked disable showing message box and the message won't show. I tried clearing the browser cache but no good.

What could be wrong?
by
I think the problem is with the message content.

Wrong message:

"
This is sample message.
This is the 2nd line.
"

Correct message:

"
This is sample message.<br />This is the 2nd line.
"
or

"
<p>This is sample message.</p><p>This is the 2nd line.</p>
"


Basically no enter should be pressed in the content. I don't know the reason :(
by
It's because you are adding the text from php to js, which splits up the lines:

$('div.qa-main').html('This is sample message.
This is the 2nd line.');

This is not kosher in js.  A quick way to fix this would be to use:

$final = str_replace("\n",'\\n',qa_opt('msg_before_ask'));

which seems to work.
by
Please check out my pull request:

https://github.com/bahar/qa_text_before_ask/pull/1

hope this is okay for you.
by
Thanks a lot for fixing it :)

I have merged the fix.
by
A new problem. The category drop down isn't loading the categories after uploading the patched files.
by
Thanks, its working now.
...