Skip to content

[Feature request] Slugs Link #2988

Description

@muh-ramadhan

I Hope The Link Slugs Function Is Added As A Text Helper In The Next Codeigniter Version.

For Example I Use a Helper.

helper('slug'); Load Slug Helper

Example slug_helper.php

function slug_link($slug) {$array = array (' ');
$array_data = array ('-', '/', '\', ',', '.', '#', ':', ';', ''', '"', '[',']', '{','}', ')', '(', '|', '`', '~', '!', '@', '%', '$', '^', '&', '*', '=', '?', '+', '–');
$slug = str_replace($array_data, '', $slug); //Remove Character From Data array_data
$trim = trim($slug); //Remove Space First And Last
$preg_replace = preg_replace('/\s+/', ' ', $trim); //Remove Doube Space
$slug = strtolower(str_replace($array, '-', $preg_replace)); //Change Single Space To - And To Lowecase
return $slug;
}

Function Save

$data = [
'slug_link' => slug_link($this->request->getPost('title')), //slug_link From Helper
];

Output Clear

text-text-text-text

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions