How to add views to topic?

@halilesen · 06 Apr 2024 · 536 views
Post Reply
User avatar
halilesen
#1 ·
Posts: 54
Joined: 24 Mar 2024, 18:09
Full Name: Halil ESEN
Has liked: 9
Been liked: 9
Maybe you want to know how many views a topic has received not only in the list on the forum pages but also in the topic itself? Here I going to show you how you can do that.

In phpBB's core, the code that shows how many times a topic has been viewed is not available for topics by default. So, you will need to edit the core files. In other words, you will have to do this every time you update. But don't worry, it won't even take a minute.

To do this, go to the root directory where you installed phpBB. Find the viewtopic.php file there and open it.

Then find the following line, probably on line 786.

Code: Select all

'TOPIC_POSTER'	=> $topic_data['topic_poster'],
And add the following code to the next line and save it.

Code: Select all

'VIEWS'			    	=> $topic_data['topic_views'],
Now you can show how many times the topic displayed by adding the variable {VIEWS} anywhere in /template/viewtopic_body.html file of your style. For example, you can use this option if want to create a special topic title.

Do you think it is necessary to do this in topics? What do you think is the best type of use?
User avatar
Dimetrodon
#2 ·
Posts: 5
Joined: 24 Sep 2024, 23:30
Full Name: Dimetrodon
Has liked: 3
Been liked: 3

Re: How to add views to topic?

halilesen wrote: 06 Apr 2024, 14:59So, you will need to edit the core files. In other words, you will have to do this every time you update.
https://www.phpbb.com/downloads/3.3/advanced_update

Advanced update has you covered. Specifically for users who have made custom edits to the core files, which sometimes have to be done, even in a world with Extensions. :D
User avatar
halilesen
#3 ·
Posts: 54
Joined: 24 Mar 2024, 18:09
Full Name: Halil ESEN
Has liked: 9
Been liked: 9

Re: How to add views to topic?

Oh yes, thanks, but since I only make a few edits and it takes about 1 or 2 minutes, I prefer to do a full update and make sure of everything.
User avatar
Dimetrodon
#4 ·
Posts: 5
Joined: 24 Sep 2024, 23:30
Full Name: Dimetrodon
Has liked: 3
Been liked: 3

Re: How to add views to topic?

Your board, your choice. :D

But I will say that I just updated my board to the final version with Advanced Update, and despite getting my hands dirty prior to somehow get two old MODs to work on the newer version of phpBB (Don't do it the way I did, it was objectively dumb to do), I was still able to use Advanced Update without any fanfare to upgrade my modified 3.3.11 board to 3.3.13.
Post Reply
  • Similar Topics