Home > Article > CMS Tutorial > 【Discuz】Realize topic title and text to be displayed at the same time
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
This is the page layout of the original mobile terminal
This is the effect that needs to be achieved
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
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
No matter what, try using this tag first and then talk
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
Since we have discovered the problem above, we will test it step by step based on this idea
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
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?
Let’s print these two variables
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
Open the local database and we will find that isn’t this the data we need?
Without further ado, let’s just print out the parameters in the address bar
Directly query based on tid, and then Put the message field in, the time is what I need! You decide according to the situation
Then we call it in the template
Check the effect: This is us Desired results
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!