Search

Hello everyone!

I’m creating a very simple database which collects various essays and articles ordered by date.

My problem is that not all the articles have a “complete” date (day/month/year), some of them have only the month (–/month/year), some others only the year (–/–/year), therefore – instead of using the usual date field – I’ve decided to create three different text input fields, one for the day, one for the month and one for the year.

When a piece of information is not available, the author simply types 00 in the field and the value is transformed in the front end into an en dash which corresponds to the missing piece of information in the formula day/month/year.

At the moment the datasource attached to the page where the list is displayed groups and sorts the various articles using the text input field “Year”, then the rest of the sorting (by day and month) is done using XSLT:

<xsl:apply-templates select="entry">
<xsl:sort select="month" order="descending"/>
<xsl:sort select="day" order="descending"/>
</xsl:apply-templates>

This allows me to achieve the result I was looking for, but I’m wondering if it is possible to avoid separating the day, the month and the year into three different text input fields and use only one (I’ve found this thread which arose my curiosity), creating a custom datasource which groups the articles taking as a reference for the grouping only a piece of the value inserted in the field (the last 4 letters corresponding to the year).

I think such a result can be achieved using XSLT:

<xsl:sort select="substring(date, 7)" order="descending"/>

but I’ve no idea if it can be done using PHP nor if Symphony allows it. Is it possible to have something like this in a custom datasource?

[…]
public $dsParamGROUP = 'substring(date, 7)';
[…]
public $dsParamSORT = 'substring(date, 7)';
[…]

I don’t know PHP so please forgive me if I’ve written such a nonsense as an example mixing PHP and XSLT, it’s just to let you get the idea!

Many thanks!

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details