


Discuz mobile terminal second launch: follow and fan pages and follow status processing
The functions implemented in this article:
Develop a mobile fan page
Develop a mobile fan page
Realize that all the watch lists you see from your own space are shown as followed
# Realize that when you look at other people’s watch lists, the users you follow are shown as followed and the users you are not following are shown Show attention
Solution to how to display the mobile page in the PHP file
source/module/home/home_follow.php This file. In this file, we only need to notice the names follow and following. One of these two means attention, the other means fans
Then we go to the template according to the access mechanism of discuz Find the file follow_follower.html. But in the template we found that the files starting with follow are just these
Then we come to the file template/default/home/follow_feed.htm. You can see two familiar modules and one follower around line 554. and following
After testing, we are convinced that this page is the loaded follow page and fan page.
#The above test will find the address request The one is /home.php?mod=follow&do=follower, but the html file loaded is template/default/home/follow_feed.htm. That is to say, if you need to load a file that is inconsistent with the requested address in dsicuz, you need to use the template function to load it.
Then let’s write a mobile follow_follower file ourselves.
##The above is how to load the second follow page and fan page in PHP
Develop fan pages and follow pages and implement data access
We can also write like this in the template. When it is judged that do is follower, enter the fan template. Enter the follow template when following
The picture below is the effect of the follow page developed by Kaka
After the page is written, we need to implement data docking. Continue back to the template/default/home/follow_feed.htm file. You can see that the data used is list, and the variable fuser is used in the loop.
##Open the discuz database dictionary and you can see whether the focus is using the mutual field.
Control the focus and use the mutual field based on the mutual field. Display and non-display of followed ones
When you enter your own space, all followed ones are displayed in the follow list. The judgment condition is when $_G[uid] == $_GET[uid] When mutual>=0, When you enter someone else’s space to view the follow list, if the user you are following needs to be shown as followed, otherwise it will be shown as followed. The judgment condition here is $_G [uid] != $_GET[uid], mutual==-1 or mutual==1 is enough. Why is there a mutual=-1 flag here? The database dictionary does not have this logo, but the actual test results show that it does. Kaka also looked at the source code and made a judgment. Just know how to judge first.
- In the watch list All link addresses are home.php?mod=spacecp&ac=follow&op=del&hash={FORMHASH}&fuid=$fuser['followuid']&mobile=2. All user IDs are followuid
- The fan list is very simple, just use -1 and 1 to judge
- that is If the value of the mutual field is 0 and 1, it can only be used when viewing the following and fan lists in your own space. If you enter the fans and attention lists of other users, a field with a mutual value of -1 will be generated
- . That is, when you enter other users, there are users you have already followed. When the value of mutual is -1
- Implementation code
// 粉丝模板 <p class="follow_manage"> <!--{if $fuser[mutual] == -1 || $fuser[mutual] == 1}--> <a id="a_followmod_{$fuser['uid']}" href="home.php?mod=spacecp&ac=follow&op=del&hash={FORMHASH}&fuid=$fuser['uid']&mobile=2" class="flw_btn_fo dialog"> <i class="iconfont icon-like_fill rq"></i> <font class="grey">已关注</font> </a> <!--{else}--> <a id="a_followmod_{$fuser['uid']}" href="home.php?mod=spacecp&ac=follow&op=add&hash={FORMHASH}&fuid=$fuser['uid']&mobile=2" class="flw_btn_fo dialog"> <i class="iconfont icon-like"></i> <font class="grey">关注</font> </a> <!--{/if}--> </p> // 关注列表模板 <p class="follow_manage"> <!--{if $_G[uid] != $_GET[uid]}--> <!--{if $fuser[mutual] == -1 || $fuser[mutual] == 1}--> <a id="a_followmod_{$fuser['followuid']}" href="home.php?mod=spacecp&ac=follow&op=del&hash={FORMHASH}&fuid=$fuser['followuid']&mobile=2" class="flw_btn_fo dialog"> <i class="iconfont icon-like_fill rq"></i> <font class="grey">已关注</font> </a> <!--{else}--> <a id="a_followmod_{$fuser['followuid']}" href="home.php?mod=spacecp&ac=follow&op=add&hash={FORMHASH}&fuid=$fuser['followuid']&mobile=2" class="flw_btn_fo dialog"> <i class="iconfont icon-like"></i> <font class="grey">关注</font> </a> <!--{/if}--> <!--{else}--> <!--{if $fuser[mutual] == 0 || $fuser[mutual] == 1}--> <a id="a_followmod_{$fuser['followuid']}" href="home.php?mod=spacecp&ac=follow&op=del&hash={FORMHASH}&fuid=$fuser['followuid']&mobile=2" class="flw_btn_fo dialog"> <i class="iconfont icon-like_fill rq"></i> <font class="grey">已关注</font> </a> <!--{else}--> <a id="a_followmod_{$fuser['followuid']}" href="home.php?mod=spacecp&ac=follow&op=add&hash={FORMHASH}&fuid=$fuser['followuid']&mobile=2" class="flw_btn_fo dialog"> <i class="iconfont icon-like"></i> <font class="grey">关注</font> </a> <!--{/if}--> <!--{/if}--> </p>
Draw a picture to explain the logical processing that the user is concerned about
Now user A, user B, user C
- Then user B enters You can see user C's
- in the follow list of user A's space. If user B has followed user C at this time, then the follow button at this time is "followed". At this time, mutual The value is -1 (in this case, you go to other people's watch list to view the user. If you have already followed the user, it will be displayed as followed, and the mutual value is -1)
- At this time, when user B returns to his user space to view the follow list, it will show that user C is in his list, but at this time the mutual value is 0. But when user C also follows user B, the mutual value is 1
- So when user B checks the watch list of his own space, he uses the mutual value of 0 and 1 to judge. When user B goes to view user A’s watch list, use mutual values of -1 and 1 to judge
- Draw a picture to explain the logical processing of fans
- Currently used user A, user B, user C
- At this time, user B only has user A accessing user C’s fan list. At this time, user A’s following status is also unfollowed, and the mutual value is 0
- If user A also follows user B, user B checks user A’s status in user C’s fan list and it is also unfollowed, and the mutual value is 0
- But when After user B follows user A, at this time user B checks user A's status in user C's fan list and it shows that he has followed user A and the mutual value is 1, indicating that they are following each other
- But when user A does not follow user B
- At this time, user B sees that user A's status is unfollowed in user C's fan list. When B follows user A, the status is followed. The value of mutual is -1
- , so in the fan list, it is judged that only when the value of mutual is -1 or 1, it is in the following state, and the rest are in the unfollowed state
- The above is the entire process of implementation. This code will be analyzed in the next article
The above is the detailed content of Discuz mobile terminal second launch: follow and fan pages and follow status processing. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

SublimeText3 Chinese version
Chinese version, very easy to use

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

PhpStorm Mac version
The latest (2018.2.1) professional PHP integrated development tool

Notepad++7.3.1
Easy-to-use and free code editor