CMS MADE SIMPLE FORGE

LISE

 

[#12422] Auto generated alias and emphasis

avatar
Created By: Benoit Rambaud (brambaud)
Date Submitted: Mon Mar 01 05:22:54 -0500 2021

Assigned To: Jeff Bosch (ajprog)
Version: 1.4.2
CMSMS Version: 2.1.5
Severity: Minor
Resolution: None
State: Open
Summary:
Auto generated alias and emphasis
Detailed Description:
Hi,

I'm a french user of CmsMadeSimple and LISE module (best ever module for CMSMS)
I got problems with generated alias and french emphais.

Please have a look to this "_to_alias_format " function version i used to have
clean generated alias.
It remove emphasis and use hyphens rather than underscores.
Hope you can put it in the next release of LISE ?
  
  /**
  * first pass to conform to a valid alias
  */
  private static function _to_alias_format($str)
  {
    // left trim up to the first letter
    $str = preg_replace('/^[^a-zA-Z0-9_\x7f-\xff]*/', '', $str);

    // remove emphasis
    $str = iconv('UTF-8','ASCII//TRANSLIT',$str);
    
    // replace ' and ’ to hyphen
    $str = str_replace("'","-", $str);
    $str = str_replace("’","-", $str);
  
    // replace any invalid characters with an hyphen
    $str = preg_replace('/[^a-zA-Z0-9_\-\x7f-\xff]/', '-', $str);
  
    // replace multiple hyphens with single hyphen
    $str = preg_replace('/-+/', '-', $str);
  
    // convert to lowercase
    $str = strtolower($str);
  
    // remove hyphen from start and end
    $str = trim($str, '-');
    
    return $str;
  }

Best regards,
Benoit


History

Comments
avatar
Date: 2022-01-31 05:04
Posted By: Franck (knarf)

Same problem here. It could be nice to have this code implemented in the next
version of LISE.