Recently I had a model where I needed a custom unique slug instead of a slug which is built from fields.
At first I thought that maybe the "builder"-option was there for that purpose but soon I realized that this is obviously not the right one.
The only left option was that I would need to create the method "getUniqueSlug" in the record class. This is of course an option and has its uses but with it you would have to reimplement the collision detection for uniqueness again which are already implemented in the getUniqueSlug-method of the sluggable class.
After reading the code several hours I came to the conclusion that this functionality is simply missing so I created a new option called "provider" which is a callback. This callback provides the equivalent of the concatenation of the table fields. The great thing about this is that you don't have to care for uniqueness or the proper urlized format because this is still taken care of by the sluggable behaviour. Thus this patch is very unobtrusive and completely backwards-compatible of course.
Usage is pretty straight-forward:
Or whatever you want to name the method which is called.
jwage responded in trac:
This is already possible if you just implement a toString() method and don't specify any fields.
But I have to disagree. If I use toString() I still have to care about the uniqueness of the slug by myself because only when fields are specified this gets called inside the code:
Otherwise only the builder-function is called.
So atm this is NOT possible.