Use the Form Wizard of phpcms v9 to implement the Q & A Consultation Function

Source: Internet
Author: User

The phpcms v9 content management system does not have a Q & A module. It only has a Form Wizard, but it has many limitations. Through the Form Wizard, we can only view information submitted by users, you cannot reply to the information submitted by the user. For example, a website of some organizations needs a function to receive and reply to a user's question. The Form Wizard alone cannot meet this requirement, however, you can use the following method to modify the Form Wizard module to implement the consulting and Q & A function.

Create a new Form Wizard "online Q & A" after phpcms v9, the table name is "online_ask", and the table name is set by yourself, as shown in.

Add fields to "online Q & A", as shown in the following example.

Is the preview effect of the form.

In this way, the user can submit the problem through this form. However, in the background, the website editing module can only view the problem through the Form Wizard module, you cannot answer questions or display the answers at the website's front-end, such.

To enable website editing to answer questions while viewing the questions, you need to make the following changes to the form module:
Open the phpcms/modules/formguide/templates/formguide_info_view.tpl.php file, and add the following content under row 28th:
<Tr>
<Td> return & nbsp; answer: </td>
<Td>
<Textarea id = "answer" cols = "80" rows = "10">
<? Php echo $ answer;?>
</Textarea>
</Td>
</Tr>
<Tr>
<Td> & nbsp; </td>
<Td> <input id = "tijiaohuida" type = "button" value = "submit answer"/> </td>
</Tr>
The above variable $ answer can be further viewed.
Add the following content under row 30th:
<Script type = "text/javascript">
$ (Document). ready (function (){
Var canshuStr = window. location. search;
Var pos = canshuStr. indexOf ("& did ");
Var posend = canshuStr. indexOf ("&", pos + 4 );
Var did_c = canshuStr. substring (pos + 5, posend );
Var answer_c = "";
$ ("# Tijiaohuida"). click (function (){
Answer_c = $ ("# answer"). val ();
$. Post ('index. php? M = formguide & c = formguide_info & a = public_answer ',{
Did: did_c,
Answer: answer_c
}, Function (json ){
If (json = 1 ){
Alert ("Answer successful ");
}
});
});
});
</Script>
Then open the phpcms/modules/formguide/formguide_info.php file and add the following code to line 56:
$ Answer = $ info ['answer'];
Add a method at the end. The Code is as follows.
Public function public_answer (){
$ Did = $ _ POST ['did'];
$ Answer = $ _ POST ['answer'];
$ Re = $ this-> db-> query ("update kc_form_online_ask set answer = '". $ answer. "', mark =' answered 'where dataid = ". $ did );
Echo $ re;
}
Then we find the data table storing the modified form in the database, and add two fields mark and answer. mark is used to mark whether the problem has been answered, and answer is used to store the answer.
The above are all changes.
In this way, the interface becomes like this when you view the issues submitted by the user.

Enter the answer and click Submit to store the answer data in the data table of the form,
At the website front-end, we can display users' questions and website editing answers, for example:

In this way, the Form Wizard module is used to implement a simple online consulting function.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.