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

[Discuz] the method of displaying topic title and text at the same time

2025-03-31 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 to realize the simultaneous display of topic title and text in [Discuz]. The editor thinks it is very practical, so I share it with you for reference. I hope you can get something after reading this article.

Project requirements

This is the page layout of the original mobile.

This is the effect that needs to be achieved.

Find a problem

In the original file `upload\ template\ default\ touch\ forum\ viewthread.htm`, we can see that the title and content are displayed separately, and the variable `$ _ Gforum _ thread] [subject] `is finally used.

At this time, there is a question, that is, how to get the content of our theme out! First, let's see what the content variable of the source code is.

When we go to line 163 of `upload\ template\ default\ touch\ forum\ viewthread.htm`, we can see that it is implemented with the variable `$ post[ message] `

No matter what, try using this label first.

At this point, the problem is very obvious. We used `$ postmessage] but showed the last content of the back topic, so let's start to solve the problem.

Solve the problem

Now that we have found the problem above, let's test it step by step according to this train of thought.

Resolution steps

Since we used the variables in the original template in html, there is a problem.

Then we need to think about what the variables we passed in the background are.

Whether there is a value for the content of this topic in the passed variable

If there is, take it directly. If not, we need to solve it ourselves.

According to the request path, which PHP file is used?

Check the address bar `address pid44`. This is the address we need.

You can see that `forum.php` is requested first, so let's open this file.

On the last line of the file is the file we finally need to enter. The variable mod can be printed by itself to see what it is.

According to the figure above, if we go directly to the file `viewthread.php`, we will see these two variables. are these two variables very familiar? aren't these the two variables used in our template?

Let's print these two variables.

At this time, it is found that there is no subject content field in the variable.

First look at the subject content stored in the table in the database.

Open the discuz database dictionary `pre_forum_ post`, which is exactly what we need.

When we open the local database, we will find that isn't this the data we need?

Don't say much, just print out the parameters of the address bar.

Query directly according to tid, and then put the message field in, the time is what I need! You decide for yourselves according to the situation.

Then we call it in the template.

Check the results: this is what we want.

On [Discuz] to achieve the topic title and text display method at the same time to share here, I hope the above content can be of some help to you, can 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