Go to main content

Textpattern CMS support forum

You are not logged in. Register | Login | Help

#1 2019-12-21 22:07:11

Myusername
Member
Registered: 2019-12-12
Posts: 63

Is it possible to filter posts from at most one week ago?

I am wanting to show you some popular posts filtered by the number of visits. For this, I am using a custom_field to store the number of visits this way:

<txp:php>
global $thisarticle;
safe_update('textpattern', 'custom_1=custom_1+1', 'ID='.$thisarticle['thisid']);
</txp:php>

Then I use the sort attribute to fit posts by custom_field like this:

<txp:article_custom limit="5" sort='custom_1 + 0 desc'>

However, I didn’t find any way to view posts just from last week. Help me?

Last edited by Myusername (2019-12-21 22:09:04)

Offline

#2 2019-12-22 00:21:05

michaelkpate
Moderator
From: Avon Park, FL
Registered: 2004-02-24
Posts: 1,324
Website

Re: Is it possible to filter posts from at most one week ago?

I am not sure about the exact PHP relative time format but this looks like it could work.

<txp:article_custom limit="5" sort='custom_1 + 0 desc' time="-1 weeks">

Offline

#3 2020-01-13 07:48:53

jakob
Admin
From: Germany
Registered: 2005-01-20
Posts: 3,937
Website

Re: Is it possible to filter posts from at most one week ago?

Myusername wrote #320651:

I am wanting to show you some popular posts filtered by the number of visits. For this, I am using a custom_field to store the number of visits this way …

Have you found a way to effectively filter out visits by search bots and scripts, which can skew the results sometimes dramatically. If there’s a server-side way, I’d be interested to hear how.

From what I’ve read, logging visits via javascript is supposed to be more effective as most (?) bots don’t process javascript.


TXP Builders – finely-crafted code, design and txp

Offline

Board footer

Powered by FluxBB