Textpattern CMS support forum
You are not logged in. Register | Login | Help
- Topics: Active | Unanswered
Limiting File Download List Items to Recent Years
How could I go about restricting <txp:file_download_list />
to show only files uploaded this current year and last year so that on 1 Jan next year everything rolls over to show the new current year’s and last year’s items.
To complicate things a wee bit, the site is on a server in the USA (Chicago) but the site is for an organisation based in Australia (Melbourne), though getting time offsets were covered here and here.
Offline
Re: Limiting File Download List Items to Recent Years
If you do not need pagination, something like this could work:
<txp:variable name="last_year"><txp:php>
echo safe_strftime('%Y')-1;
</txp:php></txp:variable>
<txp:etc_query
data='<txp:file_download_list form="my_files" sort="created desc" />'
replace="div[@data-created<{?last_year}]"
/>
with my_files
form like
<div data-created='<txp:file_download_created format="%Y" />'>
... file data ...
</div>
Offline
Re: Limiting File Download List Items to Recent Years
Possibly a better option: select the id
s of the fresh files:
<txp:variable name="fresh_files"><txp:etc_query
data='SELECT id from txp_file WHERE YEAR(created) >= <txp:variable name="last_year" /> ORDER BY created desc'
break=",">{id?}</txp:etc_query></txp:variable>
and use it as id attribute of <txp:file_download_list />
.
Offline
Re: Limiting File Download List Items to Recent Years
Thank you very much, Oleg. I will try both options. I am grateful for your help.
Last edited by joebaich (2012-09-05 03:31:25)
Offline