Forum

Thread tagged as: Question, Problem, Field-Types

Slug from Date+Text Fields

Drew, in this post (https://forum.grabaperch.com/forum/08-25-2015-unique-url-for-list-and-detail-page) you stated,

"If date is a date field, you'll need to address the components of the date individually"

date-year
date-month
date-day

How would you write this if you are trying to combine a date and text field to create a unique slug?

I'm trying to create a link formated as follows:

=2016-02-24-title-of-event

<perch:content id="calendarSlug" type="slug" for="eventDateTime-year - eventDateTime-month - eventDateTime-day - eventTitle"  />
Seth Girardin

Seth Girardin 0 points

  • 5 years ago

Yes, this sure would be handy.

Drew McLellan

Drew McLellan 2638 points
Perch Support

You should be able to use:

for="eventDateTime_year eventDateTime_month eventDateTime_day eventTitle"

One more question: Do you have to include all three date components for it to work in slug?

Initially as a test, I had just eventDateTime_year and eventTitle it didn't work, just returned eventTitle as the slug. I even swapped out other ID's to make sure the template was refreshing (and it was).

for="eventDateTime_year eventTitle"

Does this information below appear anywhere in the docs? (if so, couldn't find it)

date-year
date-month
date-day

THANK YOU :)

That worked great. Sometimes the undocumented features are just what you need. Thanks to both Seth and Drew.