Код |
---|
<? // файл /bitrix/php_interface/init.php // регистрируем обработчик AddEventHandler("iblock", "OnBeforeIBlockElementUpdate", Array("MyClass", "OnBeforeIBlockElementUpdateHandler")); class MyClass { // создаем обработчик события "OnBeforeIBlockElementUpdate" Before After function OnBeforeIBlockElementUpdateHandler(&$arFields) { CModule::IncludeModule("iblock"); $res = CIBlockElement::GetProperty("17", $arFields["ID"], "sort", "asc", Array("CODE"=>"PHOTO_MINI")); if($arFields2 = $res->GetNext()) { if($arFields2["VALUE"]!="" && $arFields2["IBLOCK_ID"]=="17" && $arFields["DETAIL_PICTURE"]["old_file"]=="") { $arFields["DETAIL_PICTURE"]["old_file"]=$arFields2["VALUE"]; } } /*?><pre><? print_r($arFields); ?></pre><?exit();*/ } } ?> |
Код |
---|
<? // файл /bitrix/php_interface/init.php // регистрируем обработчик AddEventHandler("iblock", "OnBeforeIBlockElementUpdate", Array("MyClass", "OnBeforeIBlockElementUpdateHandler")); class MyClass { // создаем обработчик события "OnBeforeIBlockElementUpdate" Before After function OnBeforeIBlockElementUpdateHandler(&$arFields) { CModule::IncludeModule("iblock"); $res = CIBlockElement::GetProperty("17", $arFields["ID"], "sort", "asc", Array("CODE"=>"PHOTO_MINI")); if($arFields2 = $res->GetNext()) { if($arFields2["VALUE"]!="" && $arFields2["IBLOCK_ID"]=="17" && $arFields["DETAIL_PICTURE"]["old_file"]=="") { $res2 = CIBlockElement::GetByID($arFields["ID"]); if($ar_res = $res2->GetNext()) $ar_res["DETAIL_PICTURE"]=$arFields2["VALUE"]; } } /*?><pre><? print_r($ar_res); ?></pre><?exit();*/ } } ?> |
Код |
---|
<? // файл /bitrix/php_interface/init.php // регистрируем обработчик AddEventHandler("iblock", "OnBeforeIBlockElementUpdate", Array("MyClass", "OnBeforeIBlockElementUpdateHandler")); class MyClass { // создаем обработчик события "OnBeforeIBlockElementUpdate" Before After function OnBeforeIBlockElementUpdateHandler(&$arFields) { CModule::IncludeModule("iblock"); $res = CIBlockElement::GetProperty("17", $arFields["ID"], "sort", "asc", Array("CODE"=>"PHOTO_MINI")); if($arFields2 = $res->GetNext()) { if($arFields2["VALUE"]!="" && $arFields2["IBLOCK_ID"]=="17" && $arFields["DETAIL_PICTURE"]=="") { $arFields["DETAIL_PICTURE"]=$arFields2["VALUE"]; } } } } ?> |
Код |
---|
<? // файл /bitrix/php_interface/init.php // регистрируем обработчик AddEventHandler("iblock", "OnBeforeIBlockElementUpdate", Array("MyClass", "OnBeforeIBlockElementUpdateHandler")); class MyClass { // создаем обработчик события "OnBeforeIBlockElementUpdate" Before After function OnBeforeIBlockElementUpdateHandler(&$arFields) { CModule::IncludeModule("iblock"); $res = CIBlockElement::GetProperty("17", $arFields["ID"], "sort", "asc", Array("CODE"=>"PHOTO_MINI")); if($arFields2 = $res->GetNext()) { if($arFields2["VALUE"]!="" && $arFields2["IBLOCK_ID"]=="17" && $arFields["PREVIEW_PICTURE"]["old_file"]=="") { $arIBlock = CIBlock::GetArrayByID("17"); $im = $arFields2['VALUE']; $imcopy = CFile::CopyFile($im); $imcopy = CFile::MakeFileArray($imcopy); $arFields["PREVIEW_PICTURE"] = CIBlock::ResizePicture( $imcopy, $arIBlock["FIELDS"]["PREVIEW_PICTURE"]["DEFAULT_VALUE"]); } } } } AddEventHandler("iblock", "OnAfterIBlockElementAdd", Array("MyClass1", "OnAfterIBlockElementAddHandler")); class MyClass1 { // создаем обработчик события "OnAfterIBlockElementAdd" Before After function OnAfterIBlockElementAddHandler(&$arFields) { CModule::IncludeModule("iblock"); $res = CIBlockElement::GetProperty("17", $arFields["ID"], "sort", "asc", Array("CODE"=>"PHOTO_MINI")); if($arFields2 = $res->GetNext()) { if($arFields2["VALUE"]!="" && $arFields2["IBLOCK_ID"]=="17" && $arFields["PREVIEW_PICTURE"]["old_file"]=="") { $arIBlock = CIBlock::GetArrayByID("17"); $im = $arFields2['VALUE']; $imcopy = CFile::CopyFile($im); $imcopy = CFile::MakeFileArray($imcopy); $arFields["PREVIEW_PICTURE"] = CIBlock::ResizePicture( $imcopy, $arIBlock["FIELDS"]["PREVIEW_PICTURE"]["DEFAULT_VALUE"]); } } } } ?> |