Allows you to add wordpress style year/month URLs to time-sensitive sections of your website
This module allows you to create dated urls, that is, links that have the year and month preceeding the url segment.
This is useful if you want your blog posts, or other date-specific sections of the website, to indicate when they
were posted. This follows the same style as wordpress, and other blog applications.
For instance, if you had a blog with urls like
You could turn these links into:
Dated style urls can only be applied to subpages, grouped under common holder pages of a list of specified types.
composer require "tractorcow/silverstripe-datelink": "3.1.*@dev"
The reason for using a cached XML file for storing routing patterns is that database access is not available before
routes are initialised. All required parent pages and years are extracted during dev/build to create distinct patterns
that silverstripe can use during routing, to prevent clashes between it and the default page routing. These routes are
then simply read from the XML file and set in the routing table each page load.
See DateLink.yml for the basic configuration options.
To setup date customised links you should configure the class names of each child and parent relations. The only
mandatory property to set is the
DateLink.holder_classes config property to specify the parent classes of all dated
DateLink: holder_classes: - 'BlogHolder'
By default all children of the specified classes will have dated urls applied to them. In order to further filter out
these classes an additional filter may be applied, the
DateLink.child_classes config property.
For example, to filter only 'BlogEntry' pages:
DateLink: child_classes: - 'BlogEntry'
You can customise the URL layout using constants, year, month (name/number), day of the month, and even day of the
week using the configuration property
DateLink: url_pattern: '$ParentLink!/$Year!/$Month!/$URLSegment!//$Action/$ID/$OtherID'
The following pattern placeholders can be used here:
All wildcards prior to the '//' must be qualified with a trailing '!'
The field which holds the date for each page can be customised by one of two ways:
DateLink.default_date_fieldconfig option will set the default field. By default this is 'Created'
getRouteDatefunction in your Page class to return the date value that should be used for that page.
Copyright (c) 2013, Damian Mooyman
All rights reserved.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
Module rating system helping users find modules that are well supported. For more on how the rating system works visit Module standards
Score not correct? Let us know there is a problem