Skip to content
Bitrix snippets for SublimeText
PHP
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
messages
LICENSE
README.md
bitrix-advertising.banner.sublime-snippet
bitrix-breadcrumb.sublime-snippet
bitrix-catalog.bigdata.products.sublime-snippet
bitrix-catalog.brandblock.sublime-snippet
bitrix-catalog.comments.sublime-snippet
bitrix-catalog.compare.list.sublime-snippet
bitrix-catalog.compare.result.sublime-snippet
bitrix-catalog.discsave.info.sublime-snippet
bitrix-catalog.element.sublime-snippet
bitrix-catalog.export.1c.sublime-snippet
bitrix-catalog.filter.sublime-snippet
bitrix-catalog.import.1c.sublime-snippet
bitrix-catalog.link.list.sublime-snippet
bitrix-catalog.main.sublime-snippet
bitrix-catalog.recommended.products.sublime-snippet
bitrix-catalog.search.sublime-snippet
bitrix-catalog.section.list.sublime-snippet
bitrix-catalog.section.sublime-snippet
bitrix-catalog.sections.top.sublime-snippet
bitrix-catalog.set.constructor.sublime-snippet
bitrix-catalog.smart.filter.sublime-snippet
bitrix-catalog.socnets.buttons.sublime-snippet
bitrix-catalog.store.amount.sublime-snippet
bitrix-catalog.store.detail.sublime-snippet
bitrix-catalog.store.list.sublime-snippet
bitrix-catalog.store.sublime-snippet
bitrix-catalog.sublime-snippet
bitrix-catalog.top.sublime-snippet
bitrix-catalog.viewed.products.sublime-snippet
bitrix-currency.rates.sublime-snippet
bitrix-eshop.facebook.plugin.sublime-snippet
bitrix-event_list.sublime-snippet
bitrix-fileman.light_editor.sublime-snippet
bitrix-highloadblock.list.sublime-snippet
bitrix-highloadblock.view.sublime-snippet
bitrix-iblock.element.add.form.sublime-snippet
bitrix-iblock.element.add.list.sublime-snippet
bitrix-iblock.element.add.sublime-snippet
bitrix-iblock.tv.sublime-snippet
bitrix-iblock.vote.sublime-snippet
bitrix-iblock.wizard.sublime-snippet
bitrix-infoportal.element.add.form.sublime-snippet
bitrix-main.app.passwords.sublime-snippet
bitrix-main.calendar.interval.sublime-snippet
bitrix-main.clock.sublime-snippet
bitrix-main.colorpicker.sublime-snippet
bitrix-main.feedback.sublime-snippet
bitrix-main.include.sublime-snippet
bitrix-main.map.sublime-snippet
bitrix-main.profile.sublime-snippet
bitrix-main.register.sublime-snippet
bitrix-main.site.selector.sublime-snippet
bitrix-main.user.link.sublime-snippet
bitrix-map.google.search.sublime-snippet
bitrix-map.google.system.sublime-snippet
bitrix-map.google.view.sublime-snippet
bitrix-map.yandex.search.sublime-snippet
bitrix-map.yandex.system.sublime-snippet
bitrix-map.yandex.view.sublime-snippet
bitrix-menu.sections.sublime-snippet
bitrix-menu.sublime-snippet
bitrix-news.detail.sublime-snippet
bitrix-news.index.sublime-snippet
bitrix-news.line.sublime-snippet
bitrix-news.list.mail.sublime-snippet
bitrix-news.list.sublime-snippet
bitrix-news.sublime-snippet
bitrix-player.sublime-snippet
bitrix-rss.out.sublime-snippet
bitrix-rss.show.sublime-snippet
bitrix-sale.basket.basket.small.mail.sublime-snippet
bitrix-sale.location.selector.search.sublime-snippet
bitrix-sale.location.selector.steps.sublime-snippet
bitrix-sale.location.selector.system.sublime-snippet
bitrix-sale.personal.order.detail.mail.sublime-snippet
bitrix-search.form.sublime-snippet
bitrix-search.page.sublime-snippet
bitrix-search.suggest.input.sublime-snippet
bitrix-security.user.otp.init.sublime-snippet
bitrix-security.user.recovery.codes.sublime-snippet
bitrix-socserv.auth.split.sublime-snippet
bitrix-statistic.table.sublime-snippet
bitrix-subscribe.form.sublime-snippet
bitrix-subscribe.index.sublime-snippet
bitrix-subscribe.news.sublime-snippet
bitrix-subscribe.simple.sublime-snippet
bitrix-support.faq.element.detail.sublime-snippet
bitrix-support.faq.element.list.sublime-snippet
bitrix-support.faq.section.list.sublime-snippet
bitrix-support.faq.sublime-snippet
bitrix-support.ticket.edit.sublime-snippet
bitrix-support.ticket.list.sublime-snippet
bitrix-support.ticket.sublime-snippet
bitrix-support.wizard.sublime-snippet
bitrix-system.auth.confirmation.sublime-snippet
bitrix-system.auth.form.sublime-snippet
bitrix-system.auth.initialize.sublime-snippet
bitrix-voting.current.sublime-snippet
bitrix-voting.form.sublime-snippet
bitrix-voting.list.sublime-snippet
bitrix-voting.result.sublime-snippet
bitrix-webservice.checkauth.sublime-snippet
bitrix-webservice.server.sublime-snippet
bitrix-webservice.statistic.sublime-snippet
bxPrintr.sublime-snippet
bx_add_head_script.sublime-snippet
bx_change_catalog_template.sublime-snippet
bx_cn_autoload.sublime-snippet
bx_composite_dinamic.sublime-snippet
bx_composite_js.sublime-snippet
bx_dump.sublime-snippet
bx_first.sublime-snippet
bx_getcurpage.sublime-snippet
bx_img_w_stub.sublime-snippet
bx_inc1.sublime-snippet
bx_isadmin.sublime-snippet
bx_lang.sublime-snippet
bx_printr.sublime-snippet
bx_resize_image_get.sublime-snippet
bx_resize_more_photo.sublime-snippet
bx_set_additional_css.sublime-snippet
bx_showhead.sublime-snippet
bx_showpanel.sublime-snippet
bx_showtitle.sublime-snippet
bx_template.sublime-snippet
channel.json
dump.sublime-snippet
generator.php
messages.json

README.md

#BitrixSnippets - Набор сниппетов для CMS Bitrix

##Набор делался для внутреннего использования, но вдруг кому-то ещё он пригодится.

Оригинальная идея и скрипт генерации сниппетов взят из этой ветки и немного доработан так, чтобы генерировать более юзабельные сниппеты.

##В наборе пока только сниппеты основных компонентов bitrix. Для вставки сниппета достаточно написать bx_ и появится окошко автокомплита. Для корректной работы сниппетов все точки в названиях компонентов заменены на _, таким образом для вставки компонента bitrix:news.list можно прописать bx_news_list.

Установка

  1. Жмём Ctrl+P. Набираем Package Control: Add Repository, жмём Enter
  2. В появившемся поле добавляем репозиторий: https://github.com/pafnuty/BitrixSnippets
  3. Жмём Ctrl+P. Набираем Package Control: Install Package, набираем BitrixSnippets и жмём Enter.
  4. Profit!

##Список кастомных сниппетов Сниппеты, добавленные вручную для удобства каждодневного использования: bx_add_head_script

<?$APPLICATION->AddHeadScript(SITE_TEMPLATE_PATH.'/js/main.js', true)?>

bx_first

<?if(!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED!==true)die();
IncludeTemplateLangFile(__FILE__);
$CurPage = $APPLICATION->GetCurPage();
?>

bx_getcurpage

$APPLICATION->GetCurPage()

bx_inc_1

<?$APPLICATION->IncludeComponent("bitrix:main.include", ".default", array(
	"AREA_FILE_SHOW" => "file",
	"PATH" => "/local/codenails/includes/file.php",
	"EDIT_TEMPLATE" => ""
	),
	false
);?>

bx_isadmin

<?
global $USER;
if ($USER->IsAdmin()) {
	
};
?>

bx_lang

<?=LANGUAGE_ID?>

bx_printr

<?echo "<pre class='cn-pre' data-text='arResult'>"; print_r($arResult); echo "</pre>";?>

bx_set_additional_css

<?$APPLICATION->SetAdditionalCSS(SITE_TEMPLATE_PATH.'/css/main.css', true)?>

bx_set_description

<?
	$ShortText = htmlspecialchars(strip_tags(stripslashes($arResult["DETAIL_TEXT"])));

	if (strlen($ShortText) > 200) {
		$ShortText = substr($ShortText, 0, 200);					
		if($word_pos = strrpos($ShortText, ' ')) $ShortText = substr($ShortText, 0, $word_pos);			
	} 
	$APPLICATION->SetPageProperty("description", $ShortText);
?>

bx_showhead

<?$APPLICATION->ShowHead();?>

bx_showpanel

<?$APPLICATION->ShowPanel();?>

bx_showtitle

<?$APPLICATION->ShowTitle(false)?>

bx_template

<?=SITE_TEMPLATE_PATH?>/

bx_resize_image_get

<?
	// Ресайз картинки для последующего показа через MagnificPopup
	$image = CFile::ResizeImageGet($arResult['DETAIL_PICTURE'], array('width'=>150, 'height'=>150), BX_RESIZE_IMAGE_PROPORTIONAL_ALT, true);
	$resizedImg = ($image['src']) ? $image['src'] : $arResult['DETAIL_PICTURE'];
?>
<img 
	class="popup-image" 
	src="<?=$resizedImg?>" 
	data-mfp-src="<?=$arResult['DETAIL_PICTURE']['SRC']?>"
	alt="<?=$arResult['DETAIL_PICTURE']['ALT']?>"
	title="<?=$arResult['DETAIL_PICTURE']['TITLE']?>"
>
// Вставка в js-файл
// Галерея картинок
$('.popup-image').magnificPopup({
	type: 'image',
	gallery: {
		enabled: true
	}
});

bx_composite_js

if (window.frameCacheVars !== undefined) {
    BX.addCustomEvent('onFrameDataReceived', mainFunction);
}
else {
    $(mainFunction);
}

function mainFunction() {
    console.log('go-go-go');
}

bxPrintr Новый, более удобный bx_printr для последней версии быстрого старта.

<?bxPrintr($arResult, false, 'arResult');?>

bx_composite_dinamic

<?
    $frame = $this->createFrame()->begin('');
    $frame->setAnimation(true);
?>
динамический контент
<?$frame->end();?>

bx_img_w_stub

<?    
    // Определяем title будущей картинки (учитываем настройки SEO-модуля и настройки инфоблока)
    $strTitle = (
        isset($arResult["IPROPERTY_VALUES"]["ELEMENT_DETAIL_PICTURE_FILE_TITLE"]) && $arResult["IPROPERTY_VALUES"]["ELEMENT_DETAIL_PICTURE_FILE_TITLE"] != ''
        ? $arResult["IPROPERTY_VALUES"]["ELEMENT_DETAIL_PICTURE_FILE_TITLE"]
        : $arResult['NAME']
    );
    // Определяем alt будущей картинки (учитываем настройки SEO-модуля и настройки инфоблока)
    $strAlt = (
        isset($arResult["IPROPERTY_VALUES"]["ELEMENT_DETAIL_PICTURE_FILE_ALT"]) && $arResult["IPROPERTY_VALUES"]["ELEMENT_DETAIL_PICTURE_FILE_ALT"] != ''
        ? $arResult["IPROPERTY_VALUES"]["ELEMENT_DETAIL_PICTURE_FILE_ALT"]
        : $arResult['NAME']
    );

    // Cоздаём массив, отвечающий за картинку по умолчанию, если нет других картинок
    // Нам нужен только один ключ т.к. остальное уже определено выше
    $defImgArray = array(
        'SRC' => '/local/codenails/images/content/noimage270.png'
    );
    $prewiewImgUrl = (is_array($arResult["PREVIEW_PICTURE"])) ? $arResult["PREVIEW_PICTURE"] : $defImgArray;

?>
<div <?if (isset($arResult["DETAIL_PICTURE"]["SRC"])):?>class="image-popup" data-mfp-src="<?=$arResult["DETAIL_PICTURE"]["SRC"]?>"<?endif?> title="<?=$strTitle?>"><img src="<?=$prewiewImgUrl['SRC']?>" alt="<?=$strAlt?>"></div>

bx_resize_more_photo

<?
/**
 * Правильный ресайз картинок, загруженных как допсвойство в инфоблок
 */
?>
<?
    $arMorePhoto = array();
    if (array_key_exists("SRC", $arResult["DISPLAY_PROPERTIES"]["MORE_PHOTO"]["FILE_VALUE"])) {
        $arMorePhoto[] = $arResult["DISPLAY_PROPERTIES"]["MORE_PHOTO"]["FILE_VALUE"];
    } else {
        $arMorePhoto = $arResult["DISPLAY_PROPERTIES"]["MORE_PHOTO"]["FILE_VALUE"];
    }
?>
<?if (count($arMorePhoto) > 0):?>
    <div class="col col-5">
        <div class="content">
            <?foreach ($arMorePhoto as $key => $value):?>
                <?
                    $file = CFile::ResizeImageGet($value, array('width'=>185, 'height'=>185), BX_RESIZE_IMAGE_PROPORTIONAL_ALT, true);
                ?>
                <?if ($value["DESCRIPTION"]): ?>
                    <?$morePhotoAlt = $morePhototitle = $value["DESCRIPTION"];?>
                <?else:?>
                    <?$morePhotoAlt = $morePhototitle = $arResult['NAME']?>
                <?endif?>
                <div class="col col-6 col-margin-bottom">
                    <img 
                        src="<?=$file["src"]?>"
                        alt="<?=$morePhotoAlt?>"
                        data-mfp-src="<?=$value["SRC"]?>"
                        title="<?=$morePhototitle?>"
                        class="image-open pseudolink"
                    >
                </div>
            <?endforeach?>    
        </div>
    </div> <!-- .col col-5 -->
<?endif?>

dump

<?dump($arResult, '-s');
    // dump();
    // dump(1);
    // dump(false);
    // dump(debug_backtrace());

    // dump($arResult);
    // dump($arResult, '-d');
    // dump($arResult, '~d');
    // dump($arResult, '!d');

    // dump($arResult, 's');
    // dump($arResult, '-s');
    // dump($arResult, '~s');
    // dump($arResult, '!s');

    // dump($arResult, 'ddd');
    // dump($arResult, '-ddd');
    // dump($arResult, '~ddd');
    // dump($arResult, '!ddd');

    // dump($arResult, 'sd');
    // dump($arResult, '-sd');
    // dump($arResult, '~sd');
    // dump($arResult, '!sd');?>

You can’t perform that action at this time.