Welcome to the Question2Answer Q&A. There's also a demo if you just want to try it out.
+33 votes
22.8k views
in Plugins by
edited by

This plugin add extra fields to ask / edit form and question page. Although Q2A can add only one textbox, this plugin can add textbox / checkbox / selectionbox / radiobutton / textarea / file without any restriction. Refer to readme in download-file for description.

Views

  1. Screen shot 1: ask form
  2. Screen shot 2: page view (no design by CSS)
  3. Screen shot 3: edit form

Compatibility

Q2A V1.6, V1.7 [2014/12/30 Updated]

Update history

  • [V1.7] 2015/02/04 Add file extension check feature in case of file type field.
  • [V1.6.4] 2014/09/19  Fixed bug (If files exist on upper content, popup don't work)
  • [V1.6.3] 2014/03/16  Fixed bug (Error on none description question post)
  • [V1.6.2] 2014/03/13  Fixed bug (Post data of none moderated user is not stored on moderation mode)
  • [V1.6.1] 2014/01/09  Fixed bug when question is hided.
  • [V1.6] 2013/12/13  Add lightbox effect with responsive design.
  • [V1.5] 2013/12/05  Add textarea and file type. And, Fixed a lot of bugs.
  • [V1.4] Add required option.

Download

Have hun !!

Q2A version: 1.6, 1.7
by
This plugin is outdated, and is no longer maintained as the author left Q2A community haft a decade ago.

In short: doesn't work!
by
Link to add does not work.
by
Link to plugin does not work.
by
Is there such a plugin that works for replies as well? The user should be able to select an option when answering questions.

11 Answers

+4 votes
by
Nice plugin but one thing! Is there a way to hide the label on question page if there is no input?
by
Thank you VdoubleE for your opinion. I try improvement.
by
Perfect! This plugin is so needed thanks for listening!
+1 vote
by
Really excellent work !!

I just hope that we will have one day as well an image-field or gallery-field so we can use q2a in so many other ways.

Classifieds for example...

Thank You !!
by
Thank you monk333 for your opinion. Like forum-CMS(Bulletin board etc), it is good that  files can be attached "easily" by extra field. I feel that Jatin was developed plugin which attaches voice file too. I will further develop.
+1 vote
by
Hi sama55,
This is great!
I am looking for a way to add titles to answers and it seems that adding your text field would do the trick. Is there an easy way to also apply this feature on answers?
Would most appreciate your elaborate answer (as much as you can)
Thanks in advance.
by
Thanks karo. qa_postmetas table key is postid. Therefor, I think that you can add extra fields to answer, if you make other plugin mimicking my plugin.
by
Yeah that's the idea,
I`m new to Q2A and still trying to figure out where are the relevant values for answer form and question form and replace the two.
Would most appreciate your help on this
by
Yes i'm also facing trouble with applying this plugin to answers also. i know that i need to copy this plugin, give it a different name but what to change inside?
+1 vote
by
I have one question for this plugin, that should we have to set a particular value of attachment fields or with every attachment a next attachment file option will come forward?
+1 vote
by
Hi Sama
 
In your filter file, you have a process_event function where you declare a global $qa_extra_question_fields. You then test if it's set.
 
My questions are:
 
1) Will it ever be set?
2) Will it issue a warning if testing on a variable index not set?
 
Thanks!
 
function process_event ($event, $userid, $handle, $cookieid, $params) {
   global $qa_extra_question_fields;
   switch ($event) {
      case 'q_queue':
      case 'q_post':
      case 'q_edit':
         for($key=1; $key<=qa_eqf::FIELD_COUNT_MAX; $key++) {
            if((bool)qa_opt(qa_eqf::FIELD_ACTIVE.$key)) {
              $name = qa_eqf::FIELD_BASE_NAME.$key;
              if(isset($qa_extra_question_fields[$name]))
                 $content = qa_sanitize_html($qa_extra_question_fields[$name]['value']);
              else
                 $content = qa_db_single_select(qa_db_post_meta_selectspec($params['postid'], 'qa_q_'.$name));
              if(is_null($content))
                 $content = '';
             qa_db_postmeta_set($params['postid'], 'qa_q_'.$name, $content);
         }
    }
    break;
    case 'q_delete':
        for($key=1; $key<=qa_eqf::FIELD_COUNT_MAX; $key++) {
            if((bool)qa_opt(qa_eqf::FIELD_ACTIVE.$key)) {
               $name = qa_eqf::FIELD_BASE_NAME.$key;
               qa_db_postmeta_clear($params['postid'], 'qa_q_'.$name);
           }
       }
       break;
   }
}
by
1) Will it ever be set?
It is set in filter_question() function of qa-eqf-filter.php.

2) Will it issue a warning if testing on a variable index not set?
Because it is determined in isset() function, I think that the warning is not displayed. But, what is "variable index"? Can you show example?
by
Sorry, I'm having a little trouble debugging this php. I'll write again when I succeed :-)
by
Good. Because this plugin is old, I think that logic is strange a little. It should be remade...
by
By the way, I'm still trying to add file upload to answers and comments using your plugin. It's very difficult, but I'll keep on trying :-)
by
Because Q2A core has extra field for question as basic feature, my plugin was relatively easy. But Q2A core has not extra field feature for answer and comment. Therefore, your challenge will be more difficult. Go for it!
by
Thanks sama. My first mission is to add a File upload button below CKEditor when the user clicks answer or comment. Do you know if I have to change the core to achieve this, or if it can be done in the plugin?
by
Now, in other plugin development, I am adding item to each answer on question page.
http://www.question2answer.org/qa/34486

Because form of answer and comment are processed with Ajax, relatively high skill will be necessary. Form data are handled in functions below.

1. Form is generated in qa-include/qa-theme-base.php::a_form() / c_form()
    Probably, you will add item in array of $this->content['a_form'] / $this->content['xxx']['c_form']
2. Form data is posted to server with qa-content/qa-question.js/qa_submit_answer().
3. Form data is catched in qa-include/qa-ajax-answer.php / qa-ajax-comment.php
4. Form data is inserted into DB with qa-include/qa-page-question-submit.php::qa_page_q_add_a_submit() and qa-include/qa-app-post-create.php::qa_answer_create()

Important point is that you cannot override upper functions. Therefore, you will handle $_FILE by using filter OR event feature.

http://www.question2answer.org/modules.php?module=filter
filter_answer() / filter_comment()
Filter function is called before form data is inserted into DB.

http://www.question2answer.org/modules.php?module=event
a_queue / a_post / a_edit / c_queue / c_post / c_edit
Event function is called after form data is inserted into DB.

About DB:
Primary key of qa_postmetas table is postid. You will be able to use this table for new item.

I think that you can make plugin without changing Q2A core by using upper information well. It is incomplete information, but I'm happy if useful for you.
by
edited by
Thankyou very much Sama. I decided to create a new plugin to do the job of adding a file upload field to answer/comment, instead of modifying your EQF plugin.

I will look into your Point Trade Pro plugin when you have it ready, but until then a small question:

I have this simple layer in my new answer/comment file upload plugin:

 qa_html_theme_layer extends qa_html_theme_base
{
    function c_form($c_form)
    {
        qa_html_theme_base::c_form($c_form);
        $this->output('<INPUT TYPE="file" value="Upload file" />');
    }
}

It has a basic button with the label Upload file, just as a start.

Right now the button always shows below an existing answer. But I only want the button to show below CKEditor, when a user is writing an answer. How can I do this?

Thankyou!
by
It will be necessary to output <input/> tag inside of <form> --- </form> tag. Q2A form is output from array data made with constant rule. You can know the rule by outputting c_form.

Example :
qa_html_theme_layer extends qa_html_theme_base {
    function c_form($c_form) {
        echo '<pre>';
        echo 'c_form = ' . print_r($c_form, true).PHP_EOL;
        echo '</pre>';
        qa_html_theme_base::c_form($c_form);
    }
}

You should add your item to array ($c_form) before calling base function. Then, your item which you added will be displayed by base function.

Incomplete example :
qa_html_theme_layer extends qa_html_theme_base {
    function c_form($c_form) {
        $c_form['fields']['myitem'] = array ('type' => 'text',  'label' => '', ... );  // !!!
        qa_html_theme_base::c_form($c_form);
    }
}
by
Another method ? (Using output buffering of PHP):
This is an unorthodox method.

qa_html_theme_layer extends qa_html_theme_base {
    function c_form($c_form) {
        ob_start();
        qa_html_theme_base::c_form($c_form);
        $html = ob_get_clean();
        $mytags = '<input ... ... ...>';
        $html = str_replace('</form>', $mytags.'</form>', $html);
        $this->output_raw($html);  // output?
    }
}

http://www.php.net/manual/en/ref.outcontrol.php
http://www.php.net/manual/en/function.str-replace.php

Of course, there are other methods. However, your Q2A customization skill will improve by learning upper methods.
by
In my new plugin I now have an upload button. I have furthermore created an event file listening to comment-events (c_queue, c_post etc.). This part of the code seems to work fine.

Now I understand, that I have to take the contents of $_FILE and do something like this inside the event file:

qa_upload_file($_FILES["file"]["tmp_name"], $_FILES["file"]["name"], null, false, null, null);

But unfortunately I am stuck with an empty $_FILES. If I print the contents of $_FILES it's always empty:

Array
(
)

I know because I print the variable to a file like this:

file_put_contents('debug.txt', print_r($_FILES, true));

I even tryed to print $_FILES in a filter-file instead, but it's still empty.

I have manually added 'enctype="multipart/form-data"' to the form.

Hope you can help me out sama :-)
by
Since I do not watch your output HTML, I do not understand detailed things. Probably it will be a basic problem irrelevant to Q2A.

http://www.php.net//manual/en/features.file-upload.post-method.php
https://www.google.co.jp/webhp?sourceid=chrome-instant&ion=1&espv=2&ie=UTF-8#q=input+file+_FILES+empty
by
Hmmm, can it be the difference in the way the forms are submitted? When I submit a question the page is reloaded, but when I submit an answer/comment the page is not reloaded (it's ajax right)? Could that be the reason the $_FILE is empty when the process_event (in the event file) is called for comments/answers?
by
After further investigation, I don't think it's possible to do this file upload for answer/comment at all. Since answers/comments are not really submitted (but saved via ajax), there is no way the $_FILES is set.
by
I think this will work, however it's not easy: In the form for answer/comment, add an iframe. The iframe contains an extra form with just an input of type FILE (style it so the user won't notice the iframe) for the user to select a file to upload. Action on the form in the iframe is set to our own php-file. This php will take care of saving the file to the database. When submit button is triggered on answer/comment form (catch in new plugin -> events), we programmatically trigger the iframe submit.

Some of this ugly workaround could have been avoided if Q2A was upgraded to HTML5. Then I could have used Ajax upload plugins. I don't understand why Q2A is still running HTML4.01 - it's not like HTML5 is cutting edge :-)
0 votes
by
helo sama,

thanks for your work. i just tried to use EQF with q&a1.7 and don't seem to get it to work. i can configure the plugin in the admin section to show one file upload field, but it doesn't show up when asking a new question.

when enabling "Input is required" i get an error when trying to post a question, so it seems the plugin is active somehow only i don't see any field that i could input as a user.

is there anything i could be doing wrong?
by
This is running correctly in my environment. If there is not more detailed information, it is difficult to advice. e.g. Error contents, your theme, other plugin, etc.
by
ah, thanks for the hint: i removed all other plugins and found http://peatarian.com/blob/loginrequirement.zip as mentioned here: http://www.question2answer.org/qa/26289/how-can-i-hide-all-info-when-users-are-not-authenticated?show=26289#q26289 to be the culprit.

if i remove that plugin, yours works.
any idea how to fix that?

or an other idea to hide the questions page to unauthorized users?
by
edited by
Your code is wrong. If you call the below line in somewhere in your main function, my plugin will work correctly.
qa_html_theme_base::main();
Or, your two changes should be processed at the first of the two functions.
page_title_error() and main_parts()

Coding method of correct layer function:
http://www.question2answer.org/layers.php
Point: If you want to ensure compatibility with other plugins, you will need to call the same named parent function. e.g.
qa_html_theme_base::nav_list($navigation, $navtype);
qa_html_theme_base::head_script();
qa_html_theme_base::post_tag_list($post, $class);
qa_html_theme_base::post_meta_who($post, $class);
by
i am afraid i didn't write that code myself and am not familiar with php...anyway i tried to follow your advice and put the line
 qa_html_theme_base::main();
in line 13 of qa-login-requirement-layer.php

looks like so:
...
    function main()
        {
            qa_html_theme_base::main();
            $content=$this->content;
...

now your plugin indeed works, but this plugin is broken in that questions are now visible to unauthorized users. any more hints you could give me?
0 votes
by

Hey @sama55 !

Great plugin! I was wondering and already asked here on Q2A, how can I use Markdown/CKEditor4 instead of using the simple normal default editor on the text area field?

0 votes
by
Thanks for the plugin!

 

How can I allow only registered users to upload files?
0 votes
by
Hello, does anybody still have the source code for this plugin? because when I press the download button nothing happens and thank you.
by
Thank you, and also do you have an idea on how to make this plugin work on answers too and not only questions?
by
thanks for your work. i just tried to use EQF with q&a1.7 and don't seem to get it to work. i can configure the plugin in the admin section to show one file upload field, but it doesn't show up when asking a new question.

when enabling "Input is required" i get an error when trying to post a question, so it seems the plugin is active somehow only i don't see any field that i could input as a user.
0 votes
by
I hope someone can remake this plugin . This is really usefull
by
And also extra question field Plugin from jacksiro it doesn't work anymore
by
I am back I will try to fix the plugin. and see how best it can work now in the new php version
0 votes
by

I just came back here I will try to fix the plugin, I have the source code. and see how best it can work now in the new php version. I hope someone will be kind enough to buy me tea 

by
If that the case . Why dont you justsell this plugin ?

Or make 2 version , free and paid plugin .

As for paid plugin . I have idea .
It would interisting If the plugin have a fitur like this website https://buzzy.akbilisim.com/create

Please see the demo when create a post .

So the user  can write in additional text , add audio,   image , video , poll ,gallery or image slider, embed twitter FB instagram post or youtube video .

With this plugin I dont think need to buy premium text editor
...