OnBeforeIBlockPropertyUpdate — МиниКод http://minicode.ru записи кодов Wed, 05 Sep 2018 06:40:48 +0000 ru-RU hourly 1 https://wordpress.org/?v=4.8.14 Транслитерация и создание символьного кода свойства http://minicode.ru/transliteraciya-i-sozdanie-simvolnogo-koda-svojstva/ http://minicode.ru/transliteraciya-i-sozdanie-simvolnogo-koda-svojstva/#respond Thu, 25 Oct 2012 13:38:49 +0000 http://minicode.ru/?p=141
AddEventHandler("iblock", "OnBeforeIBlockPropertyAdd", Array("IblockModifer", "OnBeforeIBlockPropertyAddHandler"));
AddEventHandler("iblock", "OnBeforeIBlockPropertyUpdate", Array("IblockModifer", "OnBeforeIBlockPropertyUpdateHandler"));

class IblockModifer
{
    public function OnBeforeIBlockPropertyAddHandler(&$arFields)
    {
        if($arFields['IBLOCK_ID'] == 10 and empty($arFields["CODE"])){
            $arParams = array("replace_space"=>"_","replace_other"=>"_", 'change_case' => 'U', 'max_len' => 20);
            $tempCode = Cutil::translit($arFields['NAME'],"ru",$arParams);
            $arFields['CODE'] = $tempCode;
        }
    }

    public function OnBeforeIBlockPropertyUpdateHandler(&$arFields)
    {
            if($arFields['IBLOCK_ID'] == 10 and empty($arFields["CODE"])){
            $arParams = array("replace_space"=>"_","replace_other"=>"_", 'change_case' => 'U', 'max_len' => 20);
            $tempCode = Cutil::translit($arFields['NAME'],"ru",$arParams);
            $arFields['CODE'] = $tempCode;
        }
    }
}
]]>
http://minicode.ru/transliteraciya-i-sozdanie-simvolnogo-koda-svojstva/feed/ 0