Add function for URL slug

Add function for URL slug

bmx123bmx123 Posts: 13Questions: 4Answers: 1

Hello,
I'm using Editor as a custom CMS, and I've being trying to figure out how to add a function that will create URL slugs. I would like to use either of these:

https://github.com/jbroadway/urlify
https://github.com/jbroadway/urlify/blob/master/URLify.php

but I'm not at all sure how to integrate them with Editor as a simple function that can be called from Editor js file.

Any ideas would be appreciated.

Thanks

Replies

  • bmx123bmx123 Posts: 13Questions: 4Answers: 1

    In addition to my question, I thought that perhaps I can make a custom class using URLify.php, similar to the Format class, and call it in the config file, using a function such as getFormatter. Something like:

    Field::inst( 'URL' )
    ->getFormatter( 'URLify::filter')
    
    

    but I have not gotten further than simply thinking of this, I'm not sure how to implement.

  • allanallan Posts: 63,258Questions: 1Answers: 10,421 Site admin

    Try using a closure function as the get formatter - that way you can call virtually any function to do the formatting inside the closure.

    Allan

This discussion has been closed.