eZ Platform Discussions

Sort by DatePublished and field publish_date

version22

#1

Bonjour.

How to sort contents according to a “publish_date” field if it is entered and the publication date (that of the eZ system).

Content A : real publish date 10 No data in field “publish_date”
Content B : real publish date 20 Data in field “publish_date” : 05
Content C : real publish date 30 No data in field “publish_date”

I went B, A, C

        $query = new LocationQuery();

        $query->filter = new Criterion\LogicalAnd([
            new Criterion\ContentTypeIdentifier(['article', 'breve']),
        ]);
        $query->sortClauses = [
            new SortClause\DatePublished(Query::SORT_DESC),
            // new SortClause\Field('article', 'publish_date', Query::SORT_DESC), // Ne fonctionne pas pour 2 raisons. 1 il faut préciser le type. 2 on ne veux pas trier par date de publication réél puis par date de publication.
        ];

Does not work for 2 reasons. 1 the type must be specified. 2 you do not want to sort by actual publication date then by publication date.

Note: I use SOLR :slight_smile:

Merci pour votre aide.