Table of Contents

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 " >
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
Now user A, user B, user C
Home CMS Tutorial Discuz Discuz mobile terminal second launch: follow and fan pages and follow status processing

Discuz mobile terminal second launch: follow and fan pages and follow status processing

May 11, 2020 am 01:23 AM
discuz

The functions implemented in this article:

  1. Develop a mobile fan page

  2. Develop a mobile fan page

  3. Realize that all the watch lists you see from your own space are shown as followed

  4. # 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

  5. Solution to how to display the mobile page in the PHP file


##Preliminary preparation : Solve the problem of displaying the mobile page in the PHP file

In discuz, there are no fans and followers on the mobile page, so we need to develop it. The following is the development process.

The PC side of discuz has listening and audience functions. As shown below, the address home.php?mod=follow&do=follower is the corresponding fan page on the PC side

Discuz mobile terminal second launch: follow and fan pages and follow status processing


Then we can trace 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

Discuz mobile terminal second launch: follow and fan pages and follow status processing

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

Discuz mobile terminal second launch: follow and fan pages and follow status processing

## Continue to the file source/module/ Home/home_follow.php and then scroll to the end to see the loaded template. Here you can see that the loaded template is the follow_feed.html file seen above.

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 followingDiscuz mobile terminal second launch: follow and fan pages and follow status processing

Discuz mobile terminal second launch: follow and fan pages and follow status processing

Now that you have guessed it is here, write a test code to test it.

After testing, we are convinced that this page is the loaded follow page and fan page.

Discuz mobile terminal second launch: follow and fan pages and follow status processing

Discuz mobile terminal second launch: follow and fan pages and follow status processing#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.

Discuz mobile terminal second launch: follow and fan pages and follow status processing

Then adjust the browser to mobile access mode

Discuz mobile terminal second launch: follow and fan pages and follow status processing

Discuz mobile terminal second launch: follow and fan pages and follow status processing


##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

Discuz mobile terminal second launch: follow and fan pages and follow status processingThe 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.Discuz mobile terminal second launch: follow and fan pages and follow status processing

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,

Discuz mobile terminal second launch: follow and fan pages and follow status processingWhen 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[&#39;uid&#39;]}" href="home.php?mod=spacecp&ac=follow&op=del&hash={FORMHASH}&fuid=$fuser[&#39;uid&#39;]&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[&#39;uid&#39;]}" href="home.php?mod=spacecp&ac=follow&op=add&hash={FORMHASH}&fuid=$fuser[&#39;uid&#39;]&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[&#39;followuid&#39;]}" href="home.php?mod=spacecp&ac=follow&op=del&hash={FORMHASH}&fuid=$fuser[&#39;followuid&#39;]&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[&#39;followuid&#39;]}" href="home.php?mod=spacecp&ac=follow&op=add&hash={FORMHASH}&fuid=$fuser[&#39;followuid&#39;]&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[&#39;followuid&#39;]}" href="home.php?mod=spacecp&ac=follow&op=del&hash={FORMHASH}&fuid=$fuser[&#39;followuid&#39;]&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[&#39;followuid&#39;]}" href="home.php?mod=spacecp&ac=follow&op=add&hash={FORMHASH}&fuid=$fuser[&#39;followuid&#39;]&mobile=2" class="flw_btn_fo dialog">
             <i class="iconfont icon-like"></i>
             <font class="grey">关注</font>
          </a>
          <!--{/if}-->
       <!--{/if}-->
    
    </p>
    Copy after login

    Draw a picture to explain the logical processing that the user is concerned about

Now user A, user B, user C


User A follows user C

Discuz mobile terminal second launch: follow and fan pages and follow status processing

    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

When user A follows user C, user C’s fan list contains user A

Discuz mobile terminal second launch: follow and fan pages and follow status processing

    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
  • Summary
  • 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!

Statement of this Website
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

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Discuz background login problem solution revealed Discuz background login problem solution revealed Mar 03, 2024 am 08:57 AM

The solution to the Discuz background login problem is revealed. Specific code examples are needed. With the rapid development of the Internet, website construction has become more and more common, and Discuz, as a commonly used forum website building system, has been favored by many webmasters. However, precisely because of its powerful functions, sometimes we encounter some problems when using Discuz, such as background login problems. Today, we will reveal the solution to the Discuz background login problem and provide specific code examples. We hope to help those in need.

What is Discuz? Definition and function introduction of Discuz What is Discuz? Definition and function introduction of Discuz Mar 03, 2024 am 10:33 AM

"Exploring Discuz: Definition, Functions and Code Examples" With the rapid development of the Internet, community forums have become an important platform for people to obtain information and exchange opinions. Among the many community forum systems, Discuz, as a well-known open source forum software in China, is favored by the majority of website developers and administrators. So, what is Discuz? What functions does it have, and how can it help our website? This article will introduce Discuz in detail and attach specific code examples to help readers learn more about it.

A must-have for Discuz users! Comprehensive analysis of renaming props! A must-have for Discuz users! Comprehensive analysis of renaming props! Mar 12, 2024 pm 10:15 PM

A must-have for Discuz users! Comprehensive analysis of renaming props! In the Discuz forum, the name change function has always received much attention and demand from users. For some users who need to change their name, name change props can easily modify the user name, and this is also an interesting way of interaction. Let’s take an in-depth look at the renaming props in Discuz, including how to obtain them, how to use them, and solutions to some common problems. 1. Obtain name-changing props in Discuz. Name-changing props are usually purchased through points or the administrator

What should I do if I encounter an incorrect Discuz password? Quick solution sharing! What should I do if I encounter an incorrect Discuz password? Quick solution sharing! Mar 03, 2024 am 09:33 AM

What should I do if I encounter an incorrect Discuz password? Quick solution sharing! Discuz! It is a very popular forum program that provides users with a platform for convenient communication. Using Discuz! When accessing a forum, sometimes you may encounter an incorrect password, which may cause users to be unable to log in and use the forum normally. Well, meet Discuz! When the password is wrong, how should we quickly solve the problem? Some solutions will be shared below, with specific code examples provided for reference. 1. Check whether the password

Discuz background login failed? Teach you how to solve it easily! Discuz background login failed? Teach you how to solve it easily! Mar 02, 2024 pm 06:03 PM

Discuz background login failed? Teach you how to solve it easily! As Discuz, as a popular forum platform, is widely used in website construction and management, sometimes you will encounter backend login failures, which is troubling. Today we will discuss the issues that may cause Discuz backend login failure, provide some solutions, and attach specific code examples. I hope this article can help webmasters and developers who encounter similar problems. 1. Troubleshooting is to solve the problem of Discuz background login failure.

Detailed explanation of Discuz registration process: allowing you to easily modify personal information Detailed explanation of Discuz registration process: allowing you to easily modify personal information Mar 13, 2024 pm 12:21 PM

"Detailed Explanation of Discuz Registration Process: Allowing you to easily modify personal information, specific code examples are required" Discuz is a powerful community forum program that is widely used in various websites. It provides a wealth of user registration and personal information modification. functions and interfaces. This article will introduce you to Discuz's registration process in detail and provide specific code examples to help you easily customize and modify your personal information. 1. User registration process In Discuz, user registration is one of the important functions of the site. The smoothness of the registration process and

Detailed explanation of steps to modify Discuz domain name Detailed explanation of steps to modify Discuz domain name Mar 11, 2024 am 11:00 AM

Detailed explanation of the steps to modify the Discuz domain name. Specific code examples are required. With the development and operation of the website, sometimes we need to modify the domain name of the Discuz forum. This may be due to brand change, website SEO optimization, or other reasons. No matter what the reason is, modifying the Discuz domain name is a process that requires careful operation. Today we will introduce the steps of modifying the Discuz domain name in detail and provide specific code examples. Step 1: Back up data. Before modifying the domain name, you must first ensure that the website

Solve the problem that Discuz WeChat sharing cannot be displayed Solve the problem that Discuz WeChat sharing cannot be displayed Mar 09, 2024 pm 03:39 PM

Title: To solve the problem that Discuz WeChat shares cannot be displayed, specific code examples are needed. With the development of the mobile Internet, WeChat has become an indispensable part of people's daily lives. In website development, in order to improve user experience and expand website exposure, many websites will integrate WeChat sharing functions, allowing users to easily share website content to Moments or WeChat groups. However, sometimes when using open source forum systems such as Discuz, you will encounter the problem that WeChat shares cannot be displayed, which brings certain difficulties to the user experience.

See all articles