Home  >  Article  >  CMS Tutorial  >  How discuz controls the display of bullet boxes independently

How discuz controls the display of bullet boxes independently

咔咔
咔咔Original
2020-05-04 00:41:382462browse

The functions implemented in this article:

Control whether the bullet box is displayed or not

Function usage scenarios

In a previous article Wrote, discuz implements automatic registration and login. But we don't want that prompt message to come out.

After a brief search on the Internet, some said that the background can be set, but when I took a look at the back, I found that the setting was only for certain fixed scenes.

Then we can write a display method suitable for our project

Analysis of pop-up box implementation

Anyone who has used it for a while discuz knows that the front desk The pop-up box is actually determined by the background showmessage method.

We used code to trace that this method is in the upload/source/function/function_core.php file, about line 1424

How discuz controls the display of bullet boxes independently

Then we are tracking dshowmessageThis method

The final file of this method is upload/source/function/function_message.php here

Then we pull the code to the end, and we can see a variable of show_messge and a template address loaded

How discuz controls the display of bullet boxes independently

At this time we Find the location of this template: upload/template/default/touch/common/showmessage.htm

In this template we can see a variable show_message .

How discuz controls the display of bullet boxes independently

In order to confirm that the show_message in the template and the show_message in the PHP file are consistent, let’s do a test

Modification: upload /source/function/function_message.php Line 238

How discuz controls the display of bullet boxes independently

Then test the results on the page and there is no problem. The two variables are consistent

How discuz controls the display of bullet boxes independently

Implement your own display method

After the above test, we learned that the upload/source/function/function_message.php file The show_message on line 238 is consistent with the show_message of the template upload/template/default/touch/common/showmessage.htm.

Then we can declare a variable. If you want to display your own style, declare a variable and then control it in the template.

The following is a KaKa case: as long as you have this requirement KaKa Ka’s solution can 100% solve your problem

This code is to determine whether the user is registered, and if so, log in directly. (No need to worry here, Kaka’s case came from the original system.)

You can see that I added a new variable in showmessage called is_login, and the value is 1

How discuz controls the display of bullet boxes independently

Since we need to use this value in the template, let’s follow suit and declare is_login as a global variable in the upload/source/function/function_message.php file

How discuz controls the display of bullet boxes independently

Then with this value you can use it in the upload/template/default/touch/common/showmessage.htm template

Add yourself to this If is enough

How discuz controls the display of bullet boxes independently

There is also a particularly simple way to control entry in line 239 of upload/source/function/function_message.php Template

How discuz controls the display of bullet boxes independently

#So what needs to be done at this time! Just build this template

Copy the showmassge file in the upload/template/default/touch/common directory

How discuz controls the display of bullet boxes independently

Then modify this file, let Just jump directly after entering.

How discuz controls the display of bullet boxes independently

Achieve the effect

The pop-up box is gone when logging in

How discuz controls the display of bullet boxes independently

There are still things that should be found in other places

How discuz controls the display of bullet boxes independently

Summary

After summarizing the contents of this article After all the files have been modified! If you want to use your own defined template, you can use it directly

is_login is an identifier of your custom template

showmessage('login_succeed', 'forum.php',['username'=>$username,'is_login'=>1],array('showdialog' => 1));

The above is the detailed content of How discuz controls the display of bullet boxes independently. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn