Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Pages: 1
Articles modified in the last month
Can I use <txp:article_custom>
to list articles modifed in the last month? Or over a time range, in general? All the time-based tag attributes (month/time) seem to operate relative to the posted date.
The reason: articles have a numeric custom field called “Price”. But when an item is sold, the client changes the price field to ‘sold’. I want to show those products on the site for a month after they’re sold to show stock movement / drive scarcity [I realise it’s not perfect, as any article could be modified any number of times after its price field has been altered, but it’s good enough].
If there’s no way to do it, I’ll fall back on expiry and just tell the client they need to set the expiry to a month hence as well. But I was just trying to make it simpler so they only have to remember to do one thing, not two.
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Offline
Re: Articles modified in the last month
If there’s not a way, you could make a little plugin hooked onto article_save / article_publish to set the expiry field if the price field / sold field is set.
TXP Builders – finely-crafted code, design and txp
Offline
Re: Articles modified in the last month
Hey, that’s a neat idea. I like that. It also means that it’s only ever updated when the price changes from number -> sold. I might do that.
Thank you.
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Offline
Re: Articles modified in the last month
Currently, only Posted
and Expires
can be filtered, but it’s just few lines to include other date fields. Meanwhile, why wouldn’t your client just ‘Set expiry to now’ instead of modifying the price field? Then you can query sold articles with
<txp:article_custom expired time="-1 month" />
Offline
Re: Articles modified in the last month
etc wrote #339680:
why wouldn’t your client just ‘Set expiry to now’ instead of modifying the price field?
That’s an option. Probably neater and preserves the price history. I like this, thank you.
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Offline
Re: Articles modified in the last month
etc wrote #339680:
<txp:article_custom expired time="-1 month" sort="Expires desc" />...
Hmm, this is also showing non-expired articles. I only want to see ones that have expiry set. Can I exclude
the others somehow?
Trace shows:
SELECT {all the fields} FROM textpattern WHERE 1 AND `Posted` BETWEEN FROM_UNIXTIME(1744123654) AND FROM_UNIXTIME(1746715654) AND Section IN ('products') AND Status IN (4) ORDER BY Expires desc LIMIT 0, 6
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Offline
Re: Articles modified in the last month
Oops, sorry, will take a look. This one should work:
<txp:article_custom expired="now" time="-1 month" sort="Expires desc" />
Offline
Re: Articles modified in the last month
etc wrote #339685:
<txp:article_custom expired="now" time="-1 month" sort="Expires desc" />...
Perfect. Note to self: read the docs properly regarding the bit that says “Boolean, or an English date string”.
Thank you.
The smd plugin menagerie — for when you need one more gribble of power from Textpattern. Bleeding-edge code available on GitHub.
Txp Builders – finely-crafted code, design and Txp
Offline
Pages: 1