The functions implemented in this article:
Control whether the bullet box is displayed or not
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
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
Then we are tracking dshowmessage
This 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
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
.
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
Then test the results on the page and there is no problem. The two variables are consistent
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
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
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
There is also a particularly simple way to control entry in line 239 of upload/source/function/function_message.php Template
#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
Then modify this file, let Just jump directly after entering.
The pop-up box is gone when logging in
There are still things that should be found in other places
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!