generateAlias() public method

Auto-generate a page alias if it has not been set yet
public generateAlias ( mixed $varValue, DataContainer $dc ) : string
$varValue mixed
$dc DataContainer
return string
Exemplo n.º 1
0
 public function adjustAlias($value, $dc)
 {
     // Nothing to adjust if no folderUrls
     if (!$GLOBALS['TL_CONFIG']['folderUrl']) {
         return $value;
     }
     // If current page is of type folder, update children
     if ($dc->activeRecord && $dc->activeRecord->type == 'folder') {
         $childRecords = \Database::getInstance()->getChildRecords(array($dc->id), 'tl_page');
         $this->updateChildren($childRecords);
         return $value;
     }
     $tl_page = new \tl_page();
     // Clean the alias
     $value = $this->cleanAlias($value);
     try {
         $value = $tl_page->generateAlias($value, $dc);
     } catch (\Exception $e) {
         // The alias already exists so add ID just like the original method would
         $value = $value . '-' . $dc->id;
         // Validate the alias once again and throw an error if it exists
         $value = $tl_page->generateAlias($value, $dc);
     }
     return $value;
 }