2

I'm creating an events system & I want to include the venue in the url of the event along with the event name.

For now the venue name is just stored using a plain text field.

Is there an easy way in craft to convert a string & slugify it? Could I use any filter I add to Craft? Can I do it without a plugin of some sort?

I've tried the following

{ (eventVenue ? "-" ~ eventVenue | lower | replace(' ', '-') | replace('/[^\w]/','')) }

along with using Twig PCRE

{ (eventVenue ? "-" ~ eventVenue | lower | preg_replace('/[^A-Za-z0-9-]+/') ) }

Both of which give the error Expecting name or number

2

The Slugify plugin has a Twig filter that should do what you're looking for.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.