Forum
Search results urls with {braces}
Hi,
I have a doubt: in the options of a given collection, I fill the URL for single items so that I can add a link to the search results. The URL I'm adding in the options looks like this: /news/{news_date}/{slug}
.
The problem is that in my template news_date
refers to a formatted date <perch:content id="news_date" type="date" format="%Y" />
so the search url end-up like /news/2015-12-13/my-news
.
Is there any way to format the braces so that it only output the year? If no, would you have a suggestion on how to overcome this?
Thanks.
Off the top of my head - see if this works. Create a new composite field for just the year component:
And then use that in the URL:
Hi Drew,
I have tried your suggestion but it doesn't seem work.
I wonder what approach you took for 24ways for the search and how you structured the template of your collection for the date: https://24ways.org/search/?q=Test. When I click on a given search result, I do see the year in the url. Any chance you could point me at the direction you've taken?
Thanks,
Sure, it's all here: https://github.com/PerchCMS/RunwayExample-24ways