Filtering articles by newest value
This is an open discussion with 5 replies, filed under Troubleshooting.
Search
Yep, definitely possible. What you’re after is a dynamic filter on your Issue/Articles data sources.
Let’s say on your home page you want to pull out the latest Issue entry, and all of its associated Article entries. I’ll assume you have two Data Sources — Issue and Articles.
Set your Issues Data Source to pull from the Issues section, limit to 1 result, and order by System Date Descending. This will always grab the latest entry. Then at the bottom select System ID
in the Output Parameters. Refresh your page on which the Issues DS is attached and debug, adding ?debug
to the URL. Click on the “Params” link on the right and take a look at the parameter pool. You should see a new parameter in the list named $ds-issues
with a value of the ID of the latest Issue entry.
You can then use this parameter to filter your Articles DS. Edit the Articles data source and add a new Filter, selecting the “Issue” section link as the field to filter. Enter the following as the filter value:
{$ds-issue}
Re-run your page and check the debug XML — your Issues data source will run first, creating that Output Parameter. The Articles data source will run second, taking that output parameter and using it to filter its own articles.
Is that close to what you’re after?
Yep, simply create a DS that selects the newest issue (sort by date, limit to 1). Then set System ID as Parameter Output and use it as filter-param for all other DS.
That’s perfect. I never understood how parameter output worked, now I see.
Another filtering question: How can I filter only the articles with a file attached?
I can’t find anything in the documentation. regexp:.+
might work.
A new new operator not
(as in not:NULL
or not:bananas
) would be good.
It’s not documented, but looking through the PHP source code of the Upload Field I can see that the following filter examples should work:
mimetype:image/jpeg
will find entries with JPEGs — you can use any MIME typesize:1024
will find entries where files are this exact size (not very useful?!)myfile.jpg
will find entries where file name is myfile.jpg
And as phoque says, the field also supports regular expression matching. This means you can do partial matches, for example the filter value could be in the form::
mimetype:regexp:image
any files with the string “image” in their MIME type (e.g. image/jpeg, image/gif, image/png)regexp:nick
any file with the string “nick” in the file name
And so to make sure that you filter entries where they have a file, you can match on the filename with an “anything” regular expression match. So in phoque’s example:
.
means “match any character”+
means “match one or more of them”
Create an account or sign in to comment.
I’m using Symphony for a newspaper website. Since it’s mainly a copy of the printed paper, it has to be such that only the articles from the newest issue are displayed.
I have a section called issues, and every time there’s a new issue, an entry will be added there. Then I have another section called articles, with a select box link to the issues section.
What I’d like is that for most of the data sources for the articles section I create, there would be a filter on the issue field so that only the articles with the latest issue are selected. And this should be dynamic so I won’t have to go into 20 data sources and change the value every time there is a new issue.
Is this possible?