Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize the following and fan page as well as the status processing of Discuz on mobile devices?

2025-02-22 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

This article will explain in detail how Discuz implements mobile second-opened attention, fan page and attention status processing. The content of the article is of high quality, so the editor will share it for you as a reference. I hope you will have some understanding of the relevant knowledge after reading this article.

This paper implements the function:

Develop a mobile concern page

Develop mobile fan pages

Implement that the watch list seen from your own space shows that you have followed.

When you look at the other people's follow list, the users you follow show that you have followed the users you did not follow.

Solve how to display the mobile page in the PHP file

Preparation: solve the problem of displaying the mobile page in the PHP file

In discuz, the mobile end has no fans and pays attention to the page, so we need to develop it. Here is the development process.

The PC side of discuz has the function of listening and listening. The following figure shows that the home.php?mod=follow&do=follower address is the fan page on the corresponding PC.

Then we can trace the PHP file source/module/home/home_follow.php to this file. In this file, we only need to pay attention to the names follower and following. One of these two means attention and the other means fans.

Then according to the access mechanism of discuz, let's go to the template to find the follow_follower.html file. But in the template, we found that these are the only files that start with follow.

Go on to the file source/module/home/home_follow.php and pull it to the end to see the loaded template. Here you can see that the loaded template is the follow_feed.html file seen above.

So we come to the template/default/home/follow_feed.htm file, and we can see two familiar modules, follower and following, in about 554 lines.

Now that you've guessed it's here, write a test code to test it.

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

In the above test, you will find that the address request is / home.php?mod=follow&do=follower, but loading the html file is template/default/home/follow_feed.htm. In other words, if you need to load a file that is inconsistent with the request address in dsicuz, you need to use the template function to load it.

So let's write a mobile follow_follower file by ourselves.

Then the browser can be adjusted to mobile access mode.

This is how to load the second follow page and fan page PHP.

Develop fan pages and follow pages and achieve data access

We can also write this in the template. Enter the fan template when you judge do as follower, and enter the follow template when you follow.

The following picture shows the effect of Kaka developer's attention page.

Then we need to implement data docking when the page is finished. Go back to the template/default/home/follow_feed.htm file. You can see that the data used is list, and the variable fuser is recycled.

Achieve focus on display and non-display

Open the discuz database dictionary and see if you are interested in using the mutual field.

According to the mutual field, you can control the display and non-display of concerns and concerns.

When you enter your own space, you will show all your followers on the watch list. The judgment condition is mutual > = 0 when $_ G [uid] = $_ get [uid].

When you enter other people's space to view the follow list, if the user you follow needs to show that you have followed, otherwise you can show your following. the judgment condition here is $_ G [uid]! = $_ get [uid], mutual==-1 or mutual==1. Why there is a mutual=-1 logo here. There is no such mark in the database dictionary, but there is some in the actual test. Kaka also looked at the source code and made a judgment. Just know it first.

All the link addresses in the watch list are home.php?mod=spacecp&ac=follow&op=del&hash= {FORMHASH} & fuid=$fuser ['followuid'] & mobile=2. All user identities are followuid.

The fan list is very simple, just use-1 and 1 to judge.

In other words, the mutual field with values of 0 and 1 can only be used when viewing followers and fan lists in your own space. If you enter the fan and follower lists of other users, you will generate a field with a value of-1 for mutual.

That is, when you enter other users and have users you already follow, the value of mutual is-1.

The implementation code / / fan template has been followed.

/ / the watch list template has been followed

Drawing to explain the logical processing of user concern

Now user A, user B, user C

User A follows user C

Then user B enters the follow-up list in user A space and you can see user C.

If user B has followed user C at this time, the following button is followed at this time, and the value of mutual at this time is-1 (in this case, you check the user on someone else's follow list. If you have followed, you will show that you have followed, and the value of mutual is-1).

At this time, user B will display user C in his own list when he returns to his user space to view the follow list, but at this time the value of mutual is 0. But when user C also follows user B, the value of mutual is 1.

So when user B looks at the watch list in his own space, use the mutual values of 0 and 1 to judge. When user B goes to view user A's watch list, use mutual of-1 and 1 to determine

Draw pictures to explain the logical treatment of fans

Active user A, user B, user C

When user A follows user C, the fan list of user C is that of user A.

At this time, user B accesses user C's fan list only user A, and user A's follow status is also unfollowed, and mutual's is 0.

If user An also follows user B, user B checks in user C's fan list that user A's status is also unfollowed and the value of mutual is 0

But when user B follows user A, user B looks at user C's fan list to see that user A's status is followed and a mutual value of 1 indicates mutual concern.

But when user A does not follow user B

At this time, user B sees in the fan list of user C that the status of user An is not followed. When user An is followed by user B, the value of mutual is-1.

Therefore, it is judged in the fan list that only when the value of mutual is-1 or 1, it is followed, and the rest are not followed.

This is the end of the sharing of Discuz's attention and fan pages and attention status processing on the mobile side. I hope the above content can be of some help and learn more knowledge. If you think the article is good, you can share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report