Hallo zusammen,
wie kann ich verhindern das Unterstriche ( _ ) in Bindestriche ( - ) umgewandelt werden, die im SEO-Urls Artikel Template angegeben werden?
aus:
{sCategoryPath articleID=$sArticle.id}/{$sArticle.name}_{$sArticle.ordernumber|replace:"CD":""}.html
wird: Loire/Saumur-Tresor-Blanc-Brut-2015-Bouvet-Ladubay - 78489.html statt Loire/Saumur-Tresor-Blanc-Brut-2015-Bouvet-Ladubay_78489.html
Mit eigenem Plugin den Slug Service dekorieren:
coreSlugService = $core;
}
/**
* Return a URL safe version of a string.
*
* @param string $string
* @param string|null $separator
*
* @return string
*/
public function slugify($string, $separator = null)
{
$string = html_entity_decode($string);
// hier deine Regeln, als Beispiel Durchmesserzeichen in Wort
// durchmesser geändert
$string = str_replace("Ø","durchmesser",$string);
return $this->coreSlugService->slugify($string, $separator);
}
}
// services xml
1 „Gefällt mir“
Das war der richtige Tipp, vielen Dank langnickel.
Für das Beispiel in der obigen Fragestellung lautet die slugify Methode zur Lösung dann:
public function slugify($string, $separator = null) {
$string = html_entity_decode($string);
$slogresult = $this->coreSlugService->slugify($string, $separator);
$converted = preg_replace('/\Q-\E(\d{5,})/', '_$1', $slogresult, 1);
return $converted;
}