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.