phpcms webpage replacement verification code function and search function

When using phpcms to replace web pages, in addition to the normal replacement of columns, content pages, etc., other verification codes, form submission, search function, these may have some small changes to some default files when replacing

The following is the process of my own success in failure, and finally replaced with a bug-free replacement. Author: Yue~

One, phpcms verification code replacement

Where there is a verification code, it is usually a form, so the form must be made first. The form making process is very simple, as follows:

A. make a form

(1) Log in to your own phpcms background management

(2) After logging in, follow these steps to add a form

  a. Module------form wizard: as shown in the figure

  b. After opening the form wizard, click the "Add Form Wizard" button, as shown in the figure:

  c. Open the dialog box to add information, click OK

  d. After confirming, the newly added form will appear in this window, as shown in the figure:

 

(3) Add fields to the form

  a. Click the "Add Field" button in the current page to open the Add Field window

  b. Add information in the add field window (set each one in the window, such as field type, length, field name, etc.)

  c. After clicking "Submit", this field has been added successfully, and you can view all the fields you have added.

  Click "Manage Fields" to view all added field information

 

  d. So that the form is there, add the form to the replaced web page, just copy this js sentence, as shown in the figure:

Copy this sentence to the corresponding place in the webpage.

 

The form is here, you can see the style of the form, and click the "Preview" button.

(3) Modify the beginning information of the form

  After adding it to the web page normally, such a style will appear, as shown in the figure:

  a. Open the default template folder of your own phpcms template, as shown in the figure

  b. Open the default folder, find the "show_js.html" file in the "formguide" folder, and open the file, as shown in the figure:

     

  c. In the open show_js.html file, modify this location, as shown in the figure:

In this case, the form is really over

 

B. Add captcha to form

  (1) Add a field name "Verification Code", this step has all the above, not detailed

  (2) In the same default folder, find the "show_js.html" file in the "formguide" folder and open the file

Add such a piece of code at this location, as shown in the figure:

The added code is as follows:

1
2
< tr >  < th  style=" border:0px;">< font  color="red">*</ font >验证码:</ th > < td  style=" border:0px;">  < input  name="code" type="text" id="code" size="10"  class="input-text" style="width:492px;"/></ td > </ tr >
< tr >< th  style=" border:0px;"></ th >< td  style=" border:0px;">< img  id='code_img' onclick='this.src=this.src+"&"+Math.random()'  src='{APP_PATH}api.php?op=checkcode&code_len=4&font_size=14&width=110&height=30&font_color=&background=' width="201" height="50"> </ td ></ tr >

  (3) After the files in the default template are modified, one more place needs to be modified, which is to change the index.php file under \modules\formguide, as shown in the figure

If you want to find this folder, the same is stored in the phpcms folder

         

 

Open the file and add such a code, the addition location is as shown in the figure:

The added code is as follows:

1
$session_storage  'session_' .pc_base::load_config( 'system' , 'session_storage' ); pc_base::load_sys_class( $session_storage );

 

In this way, the verification code is completed, as shown in the figure:

Clicking on the picture can also modify the content of the verification code.

 

Through continuous attempts, this is the complete step to replace the verification code~~~~~

To see the form submitted by the user, you can check this place:

To the right of each form, click on "Information List":

Entering the information list, you can view those people who have added the form and what they submitted, as shown in the figure:

 

 

 

 2. Search function

The so-called full-site search function is actually a website search based on the input content.

Step 1: Submit and write the form form on the search page. I won't say much about how to write the form form.

1
2
3
4
5
6
7
8
< form  name="search" id="" action="{APP_PATH}index.php" method="get" style="170px; display:inline-block; float:left">
            < h1 >产品搜索:</ h1 >< input  name="q" value="请输入查询关键词" type="text"  onclick="javascript:document.getElementById('q').value='';" id="q" style="width:186px; height:22px; border-right-width:0px; margin-top:7px;"/>< input  id="siteid" type="hidden" value="1" name="siteid">< input  type="submit" name="submit" id="submit" value="立即搜索" style="width:60px; height:26px; border:0px;
             <!--文字输入框--> < br >        < input  type="hidden" value="search" name="m">   <!--进行搜索的页面-->
             < input  type="hidden" value="index" name="c">    <!--搜完成功后返回的页面-->
             < input  type="hidden" value="init" name="a">
             < input  id="typeid" type="hidden" value="1" name="typeid">  <!--typeid的类型-->
                                 
</ form >

  

In this way, the content you want to find is passed into the index.php file for processing (the index.php file is in modules/search/index.php). This php file is to judge and process the various values ​​passed in above.

as the picture shows:

 

Step 2: The page returned by this form form

The page of this return value is not a column page, nor a list page, nor a content page, but a separate file.

(1) Create a search folder under your own template: the path is as follows:

It is not created in the content file, but the search folder is created outside it

(2) There are so many files in the search folder (split by their own return page)

Divide a whole static page into several parts like other pages: header, footer, index, list and other 4 page files

(3) Display of search results

I won't say much about splitting, I know that phpcms will be split, and now I am modifying the index page and list page

The index page is to search for the page returned when there is no content. This page can be set by yourself, or you can use the default page of phpcms.

The list page is the result page of the search. Reminder: In addition to the content to be displayed on this page, other content should not be traversed and displayed, because this will cause errors in the search results and will not display the search results.

The traversal code for displaying the search result page is as follows: (put this in the position you want to display, and modify the style according to your own style)

1
2
3
4
5
6
7
8
9
10
11
12
13
< ul >
       {loop $data $i $r}
                          
       {if $r['thumb']}   <!--搜索的结果的图片-->
       < li >< b >< a  href="{$r[url]}">< img  src="{$r[thumb]}" /></ a ></ b > <!--搜索的结果图片和路径-->
       {/if}
       < h3 >< a  href="{$val[url]}">{$r[title]}</ a ></ h3 ></ li > <!--搜索结果的路径和标题-->
       {/loop}  
</ ul >
       {if empty($data)}未找到结果{/if}   <!--没有找到时的提示-->
       < div  id="pager" class="fy">
           {$pages}   <!--结果的分页-->
       </ div >

  

Note: You can go to the default template of phpcms to see how the files in the search folder are written. Note that there are several js files that need to be imported, so you can't write them.  

1
2
3
4
{ if  $setting[ 'suggestenable' ]}
<script type= "text/javascript"  src= "{JS_PATH}jquery.suggest.js" ></script>
<script type= "text/javascript"  src= "{JS_PATH}search_suggest.js" ></script>
{/ if }

 

Step 3: Carry out the inspection

Check the resulting page for problems:

(1) Products with "Qi" in the search station

(2) Check whether the page is out (there should be pagination if there are many things, and the searched keywords should be highlighted, which is a modification of the style)

 

At this point, the replacement of the full-site search of phpcms is over.

Points to note:

(1) The search folder is a file at the same level as the template content

(2) The files in the search folder should also be split into "head, middle, and lower"

(3) Except for the search results in all the split files, other content cannot have any search database traversal

 

In this way, all the problems encountered in the process of replacing phpcms have been solved. Wow, I have to say that this whole site search made me dizzy. Fortunately, it was completed. Now I will share the steps with you~~~

Author: Yue~

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324608265&siteId=291194637