Home > Backend Development > PHP Tutorial > About the implementation of a community system 'sidebar'

About the implementation of a community system 'sidebar'

WBOY
Release: 2016-07-06 13:51:31
Original
1012 people have browsed it

I am making a lightweight bbs program based on thinkphp.

Assume that one of the columns in the sidebar of the page is used to display user information, such as: number of posts, number of replies, avatar, user name, virtual wealth value and other information.
Another column is used to display the most popular topics in the community, or community information summary, which are dynamic data taken from the database.

How should I implement this sidebar? Because it is reused a lot and the number of sidebars called by each page is different, some pages only need to output the user information sidebar.

Can anyone provide some ideas and explain how to implement it?

The description may be unclear, so I will add more.

Reply content:

I am making a lightweight bbs program based on thinkphp.

Assume that one of the columns in the sidebar of the page is used to display user information, such as: number of posts, number of replies, avatar, user name, virtual wealth value and other information.
Another column is used to display the most popular topics in the community, or community information summary, which are dynamic data taken from the database.

How should I implement this sidebar? Because it is reused a lot and the number of sidebars called by each page is different, some pages only need to output the user information sidebar.

Can anyone provide some ideas and explain how to implement it?

The description may be unclear, so I will add more.

Extract a page to write the sidebar. The name of the sidebar is written in the backend and passed directly. Then use a loop to read the data in the page template, and then use it on whichever page it is. Proceed include.

The hottest and summary are used as shared templates respectively
Dynamically loaded during data display
You can use redis to cache all the information you need, and each page needs to be cached separately
You can only cache the data part, if it is combined with It will be more convenient to cache and obtain data together with html
Set up the cache and database data reading rules, and cache time, etc.

Front end: Define a common sidebar page, which is imported by all pages.
Backend: Define a Base class to inherit the controller. All controllers inherit Base. Use Base’s initialize() to control and display the side menu

Is that so? About the implementation of a community system 'sidebar'

You can refer to discuz. Take a look at their source code.

Related labels:
source:php.cn
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template