This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Сначала получаем id нашего раздела. Для этого воспользуемся очень удобным, но не документированным (ох уж этот Битрикс) классом CIBlockFindTools и его методом GetSectionID. В section.php перед выводом нашего заголовка пишем: | |
$arResult["SECTION_ID"] = CIBlockFindTools::GetSectionID( | |
$arResult["VARIABLES"]["SECTION_ID"], | |
$arResult["VARIABLES"]["SECTION_CODE"], | |
array("IBLOCK_ID" => $arParams["IBLOCK_ID"]) | |
); | |
$sResult = CIBlockSection::GetByID($arResult["SECTION_ID"]); | |
if($sArResult = $sResult->GetNext()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Глобальная переменная | |
Чтобы сделать переменную доступную из любого места кода, можно использовать файл bitrix/.settings.php. | |
return array ( | |
// … | |
'contacts' => array( | |
'value' => array( | |
'phone' => '111111111', | |
'email' => 'example@know-online.com', | |
), | |
), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="star-ratings-sprite"> | |
<span style="width:90%" class="star-ratings-sprite-rating"></span> | |
</div> | |
.star-ratings-sprite { | |
background: url("https://s3-us-west-2.amazonaws.com/s.cdpn.io/2605/star-rating-sprite.png") repeat-x; | |
font-size: 0; | |
height: 21px; | |
line-height: 0; | |
overflow: hidden; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Для eForm (evolutionCMS). | |
Создаем сниппет checkSpamTime, вставляем в него код: | |
<?php | |
if ($_SESSION['now']) | |
{ | |
$_SESSION['lt'] = $_SESSION['now']; | |
} | |
$_SESSION['now'] = microtime(true); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php bloginfo('template_url') ?>/images/ ссылка на папку images в шаблоне | |
/********************************************/ | |
<?php echo home_url(); ?> Ссылка на главную | |
<?php echo do_shortcode( '[ваш шорткод]' ); ?> Шорткод в шаблоне |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Создание модульных и интеграционных тестов | |
Создано и настроено окружение для использования Codeception как надстройки над PhpUnit, теперь мы можем писать тесты (не только модульные на чистом PhpUnit, но и интеграционные, требующие запущенного приложения), а ещё получать статистику по тому, какой процент кода у нас покрыт этими самыми тестами. | |
Команды: | |
vendor/bin/codecept run - запустить все тесты | |
vendor/bin/codecept run unit --coverage-html='coverage' - сформировать отчёт по степени покрытия кода тестами | |
Контроллеры тонкие, их тестировать не нужно, да и нет возможности, потому что тесты запускаются в консоли, а там нет: веб-сервера, урла, сессий, куков и т.п. Проект запускается как консольное приложение. Так что всё сошлось. | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<form class="head-search" id="NavSearchForm" action="[~46~]" method="post"> | |
<input id="search-input" placeholder="Поиск по каталогу..." class="form-control cleardefault search_place validation_place" type="text" name="search" value="" /> | |
<button class="btn btn-primary not_valid" type="submit">Найти</button> | |
</form> | |
<div class="row search-result"> | |
[[DocLister? | |
&display=`20` | |
&orderBy=`availability ASC, price ASC` | |
&parents=`7` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
usort($res, function ($a, $b) | |
{ | |
return strcmp($a["LastName"], $b["LastName"]); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
preg_match('/\((.+)\)/', $str, $m); | |
echo $m[1]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Latin(obj) { | |
if (/^[a-zA-Z0-9 ,.\-:"()]*?$/.test(obj.value)) | |
obj.defaultValue = obj.value; | |
else | |
obj.value = obj.defaultValue; | |
} | |
<input onkeyup="Latin(this);"> |
NewerOlder