Cockpit icon indicating copy to clipboard operation
Cockpit copied to clipboard

Was the 'slug' option removed from newer versions?

Open ebrenner-code opened this issue 2 years ago • 3 comments

It seems setting slug: true in the latest version of cockpit has no effect. Was it removed as an option? What is the current suggested method for automatically creating slugs for content?

ebrenner-code avatar Aug 06 '23 15:08 ebrenner-code

Just found about it too, I think it's gone, missing the feature for a customer.

pozylon avatar Sep 21 '23 23:09 pozylon

related: https://github.com/Cockpit-HQ/Cockpit/issues/26

pozylon avatar Sep 21 '23 23:09 pozylon

Hi 👋 this had multiple reasons, as it most of the times needed additional custom implementation.

How to implement a (simple) slug solution:

In your /config/bootstrap.php file (create one if not already existing) add the following code:

<?php

// add slug data to an article collection item
$app->on('content.item.save.before.articles', function(&$data) {

    // add sluggified version of the title field:
    if (isset($data['title']) && $data['title']) {
        $data['title_slug'] = $this->helper('utils')->sluggify(trim($data['title']));
    }

});

aheinze avatar Sep 21 '23 23:09 aheinze