Home > CMS Tutorial > Discuz > body text

【Discuz】Realize topic title and text to be displayed at the same time

咔咔
Release: 2020-04-29 14:52:35
Original
2527 people have browsed it

The function of this article: display the topic title and topic content at the same time. If you want to directly see the project implementation results, you can directly look at the content under the title that solves the problem

Project requirements

This is the page layout of the original mobile terminal

【Discuz】Realize topic title and text to be displayed at the same time

This is the effect that needs to be achieved

【Discuz】Realize topic title and text to be displayed at the same time

Discover the problem

In the original `upload\template\default\touch\forum\viewthread.htm` we can see that the title and content are displayed separately, and the final one is `$_G [forum_thread][subject]`This variable

【Discuz】Realize topic title and text to be displayed at the same time

There is a problem at this time, that is, how to get out our theme content! Let’s first look at what the content variables of the source code are.

Coming to line 163 of `upload\template\default\touch\forum\viewthread.htm`, we can see that `$post[message]`What this variable implements

【Discuz】Realize topic title and text to be displayed at the same time

No matter what, try using this tag first and then talk

【Discuz】Realize topic title and text to be displayed at the same time

【Discuz】Realize topic title and text to be displayed at the same time

The problem is very obvious at this time. We used `$post[message]` but it displayed the last content of the topic. Then we will start to solve this problem. Problem

Solution

Since we have discovered the problem above, we will test it step by step based on this idea

Solution steps

Since In html, there is a problem when we use variables in the original template

Then we need to think about what variables we pass in the background

Whether the variable passed in contains the theme content Value

If it exists, just get it directly. If not, we need to solve it ourselves

Check which PHP file is used according to the request path

Check the address bar` forum/upload/forum.php?mod=viewthread&tid=13&pid=44&page=1&extra=&mobile=2#pid44`This is the address we need

You can see that `forum.php` is requested first, then we Just open this file

The last line of the file is the file we finally need to enter. You can print the mod variable to see what it is

【Discuz】Realize topic title and text to be displayed at the same time

According to the above Figure, we go directly to the file `upload/source/module/forum/forum_viewthread.php`, and you will see these two variables. Are these two variables very familiar? Aren’t these the two used in our template? Variable?

【Discuz】Realize topic title and text to be displayed at the same time

Let’s print these two variables

【Discuz】Realize topic title and text to be displayed at the same time

【Discuz】Realize topic title and text to be displayed at the same time

At this time we found There is no topic content field in the variable at all

Let’s first look at the topic content stored in the database table

Open the database dictionary `pre_forum_post` of discuz. This table is exactly what we need

【Discuz】Realize topic title and text to be displayed at the same time

Open the local database and we will find that isn’t this the data we need?

【Discuz】Realize topic title and text to be displayed at the same time

Without further ado, let’s just print out the parameters in the address bar

【Discuz】Realize topic title and text to be displayed at the same time

Directly query based on tid, and then Put the message field in, the time is what I need! You decide according to the situation

【Discuz】Realize topic title and text to be displayed at the same time

Then we call it in the template

【Discuz】Realize topic title and text to be displayed at the same time

Check the effect: This is us Desired results

【Discuz】Realize topic title and text to be displayed at the same time

The above is the detailed content of 【Discuz】Realize topic title and text to be displayed at the same time. For more information, please follow other related articles on the PHP Chinese website!

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!