Getting topic content without view count?

Discussion forum for Extension Writers regarding Extension Development.
Post Reply
User avatar
Kami-sama
Registered User
Posts: 91
Joined: Sat May 26, 2018 3:07 pm

Getting topic content without view count?

Post by Kami-sama » Fri Jul 20, 2018 8:52 pm

Hey!

I am using this simple JS to get topic content and display on selected div:

Code: Select all

$(function(){
		var elem=$(".news_forum");
		if(!elem.length) return;
		
		$.get("www.URL.com", function(data){
			data=$(".content", data).last().html();
			elem.html(data);
		});
	});
It works perfectly fine, but it does activate topic view count.
So you can imagine that view count for that topic is generated pretty fast now.

I wonder if there is another way to get the content without adding to topic view count?
Or maybe I can disable view count for this specific topic?
Or maybe just leave it alone until 6 zero digits start popping up? :D

User avatar
3Di
Registered User
Posts: 12753
Joined: Mon Apr 04, 2005 11:09 pm
Location: Milan (IT) Frankfurt (DE)
Name: Marco
Contact:

Re: Getting topic content without view count?

Post by 3Di » Sat Jul 21, 2018 2:10 am

If you hit that url that's what you get.
Probably cUrl could be an alternative, not sure.
to get topic content and display on selected div
Why not to use a simple query in PHP to fetch that topic, assign the result to a row and pass it to the template? Instead.
Want to compensate me for my interest? Donate
Please PM me only to request paid works. Thx.
Extensions, Scripts, MOD porting, Update/Upgrades
My development's activity º PhpStorm's proud user

User avatar
kasimi
Extension Customisations
Extension Customisations
Posts: 2976
Joined: Sat Sep 10, 2011 7:12 pm
Location: Germany
Contact:

Re: Getting topic content without view count?

Post by kasimi » Sat Jul 21, 2018 8:04 am

Add an extra argument to your request that serves as a flag that updating the view counter should be skipped. Then, in the core.viewtopic_modify_post_data event, do this:

Code: Select all

if ($this->request->is_set('your flag', false) && isset($this->user->data['session_page']))
{
    $this->user->data['session_page'] .= '&t=' . $event['topic_id'];
}

User avatar
Kami-sama
Registered User
Posts: 91
Joined: Sat May 26, 2018 3:07 pm

Re: Getting topic content without view count?

Post by Kami-sama » Sat Jul 21, 2018 4:33 pm

3Di wrote:
Sat Jul 21, 2018 2:10 am
If you hit that url that's what you get.
Probably cUrl could be an alternative, not sure.
to get topic content and display on selected div
Why not to use a simple query in PHP to fetch that topic, assign the result to a row and pass it to the template? Instead.
Thank you for the advice. I will try it out.
Well, I am very new to PHP, this seamed like an easier way to do it. Would not even know how to do same in PHP ;D

User avatar
Kami-sama
Registered User
Posts: 91
Joined: Sat May 26, 2018 3:07 pm

Re: Getting topic content without view count?

Post by Kami-sama » Tue Aug 14, 2018 10:01 pm

kasimi wrote:
Sat Jul 21, 2018 8:04 am
Add an extra argument to your request that serves as a flag that updating the view counter should be skipped. Then, in the core.viewtopic_modify_post_data event, do this:

Code: Select all

if ($this->request->is_set('your flag', false) && isset($this->user->data['session_page']))
{
    $this->user->data['session_page'] .= '&t=' . $event['topic_id'];
}

I was trying your method, but this looks like it would apply to all topics?
Or am I missing something?

User avatar
Brf
Support Team Member
Support Team Member
Posts: 51248
Joined: Tue May 10, 2005 7:47 pm
Location: {postrow.POSTER_FROM}
Contact:

Re: Getting topic content without view count?

Post by Brf » Wed Aug 15, 2018 12:28 am

I would assume only your JS code would be using that tag the code is checking for.

Post Reply

Return to “Extension Writers Discussion”

Who is online

Users browsing this forum: No registered users and 5 guests