snipt

Ctrl+h for KB shortcuts

PHP

Транслитерация в Битрикс Cutil::translit($str, $lang, $params = array())

1
2
3
4
5
6
7
8
Cutil::translit($str, $lang, $params = array()) 
Параметры в массиве $params:
Параметр    Значение по умолчанию	Описание
"max_len"	100	Максимальная длина результата транслитерации
"change_case"	L	Приведение результата к регистру, L - к нижнему, U - верхнему
"replace_space"	_	Замена для символа пробела
"replace_other"	_	Замена для прочих символов
"delete_repeat_replace"	true	Удалять лишние символы замены
https://snipt.net/embed/602431fff0b39cce3a7799c96d8a07f5/
https://snipt.net/raw/602431fff0b39cce3a7799c96d8a07f5/
602431fff0b39cce3a7799c96d8a07f5
php
PHP
8
2016-09-26T03:26:08
True
False
True
Jun 14, 2012 at 12:04 PM
/api/public/snipt/42316/
cutiltranslitstr-lang-params-array
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a> <a href="#L-6">6</a> <a href="#L-7">7</a> <a href="#L-8">8</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="x">Cutil::translit($str, $lang, $params = array()) </span> </span><span id="L-2"><a name="L-2"></a><span class="x">Параметры в массиве $params:</span> </span><span id="L-3"><a name="L-3"></a><span class="x">Параметр Значение по умолчанию Описание</span> </span><span id="L-4"><a name="L-4"></a><span class="x">&quot;max_len&quot; 100 Максимальная длина результата транслитерации</span> </span><span id="L-5"><a name="L-5"></a><span class="x">&quot;change_case&quot; L Приведение результата к регистру, L - к нижнему, U - верхнему</span> </span><span id="L-6"><a name="L-6"></a><span class="x">&quot;replace_space&quot; _ Замена для символа пробела</span> </span><span id="L-7"><a name="L-7"></a><span class="x">&quot;replace_other&quot; _ Замена для прочих символов</span> </span><span id="L-8"><a name="L-8"></a><span class="x">&quot;delete_repeat_replace&quot; true Удалять лишние символы замены</span> </span></pre></div> </td></tr></table>
bitrix, translit

PHP

Вставка хлебных крошек

<?$APPLICATION->IncludeComponent("bitrix:breadcrumb", ".default", Array("START_FROM" => "0","PATH" => "","SITE_ID" => "-"),false);?> 
https://snipt.net/embed/f6a20d69c85871632fc9f36f6ce9878c/
https://snipt.net/raw/f6a20d69c85871632fc9f36f6ce9878c/
f6a20d69c85871632fc9f36f6ce9878c
php
PHP
1
2016-09-26T02:09:15
True
False
True
Jun 05, 2012 at 03:50 AM
/api/public/snipt/40748/
-209
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="cp">&lt;?</span><span class="nv">$APPLICATION</span><span class="o">-&gt;</span><span class="na">IncludeComponent</span><span class="p">(</span><span class="s2">&quot;bitrix:breadcrumb&quot;</span><span class="p">,</span> <span class="s2">&quot;.default&quot;</span><span class="p">,</span> <span class="k">Array</span><span class="p">(</span><span class="s2">&quot;START_FROM&quot;</span> <span class="o">=&gt;</span> <span class="s2">&quot;0&quot;</span><span class="p">,</span><span class="s2">&quot;PATH&quot;</span> <span class="o">=&gt;</span> <span class="s2">&quot;&quot;</span><span class="p">,</span><span class="s2">&quot;SITE_ID&quot;</span> <span class="o">=&gt;</span> <span class="s2">&quot;-&quot;</span><span class="p">),</span><span class="k">false</span><span class="p">);</span><span class="cp">?&gt;</span><span class="x"> </span> </span></pre></div> </td></tr></table>
bitrix

PHP

Сумма прописью, если установлен модуль sale

1
2
3
<?
Number2Word_Rus($source, $IS_MONEY = "Y");
?>
https://snipt.net/embed/cb16f59c443237b797694277dde04963/
https://snipt.net/raw/cb16f59c443237b797694277dde04963/
cb16f59c443237b797694277dde04963
php
PHP
3
2016-09-26T02:09:17
True
False
True
Jun 05, 2012 at 03:50 AM
/api/public/snipt/40703/
sale
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="cp">&lt;?</span> </span><span id="L-2"><a name="L-2"></a><span class="nx">Number2Word_Rus</span><span class="p">(</span><span class="nv">$source</span><span class="p">,</span> <span class="nv">$IS_MONEY</span> <span class="o">=</span> <span class="s2">&quot;Y&quot;</span><span class="p">);</span> </span><span id="L-3"><a name="L-3"></a><span class="cp">?&gt;</span><span class="x"></span> </span></pre></div> </td></tr></table>
bitrix

PHP

Выбор раздела инфоблока по установленным параметрам

1
2
3
<?
CIBlockFindTools::GetSectionID($section_id, $section_code, $arFilter);
?>
https://snipt.net/embed/39cf886c2d7b79562aafa395c0022d06/
https://snipt.net/raw/39cf886c2d7b79562aafa395c0022d06/
39cf886c2d7b79562aafa395c0022d06
php
PHP
3
2016-09-26T02:09:11
True
False
True
Jun 05, 2012 at 03:50 AM
/api/public/snipt/40701/
-207
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="cp">&lt;?</span> </span><span id="L-2"><a name="L-2"></a><span class="nx">CIBlockFindTools</span><span class="o">::</span><span class="na">GetSectionID</span><span class="p">(</span><span class="nv">$section_id</span><span class="p">,</span> <span class="nv">$section_code</span><span class="p">,</span> <span class="nv">$arFilter</span><span class="p">);</span> </span><span id="L-3"><a name="L-3"></a><span class="cp">?&gt;</span><span class="x"></span> </span></pre></div> </td></tr></table>
bitrix

PHP

Выбор элемента инфоблока по установленным параметрам

1
2
3
<?
CIBlockFindTools::GetElementID($element_id, $element_code, $section_id, $section_code, $arFilter);
?>
https://snipt.net/embed/eb721956212f16c4e8a99f162b0c108e/
https://snipt.net/raw/eb721956212f16c4e8a99f162b0c108e/
eb721956212f16c4e8a99f162b0c108e
php
PHP
3
2016-09-26T02:09:09
True
False
True
Jun 05, 2012 at 03:50 AM
/api/public/snipt/40700/
-206
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="cp">&lt;?</span> </span><span id="L-2"><a name="L-2"></a><span class="nx">CIBlockFindTools</span><span class="o">::</span><span class="na">GetElementID</span><span class="p">(</span><span class="nv">$element_id</span><span class="p">,</span> <span class="nv">$element_code</span><span class="p">,</span> <span class="nv">$section_id</span><span class="p">,</span> <span class="nv">$section_code</span><span class="p">,</span> <span class="nv">$arFilter</span><span class="p">);</span> </span><span id="L-3"><a name="L-3"></a><span class="cp">?&gt;</span><span class="x"></span> </span></pre></div> </td></tr></table>
bitrix

PHP

Перехват SQL запросов в коде Bitrix

1
2
3
4
5
6
<?
$GLOBALS['DB']->DebugToFile = true;
/// КОД ///
$GLOBALS['DB']->DebugToFile = false;
// потом смотрим в /mysql_debug.php
?>
https://snipt.net/embed/3d63fb5320eeca27fdfd57043f396088/
https://snipt.net/raw/3d63fb5320eeca27fdfd57043f396088/
3d63fb5320eeca27fdfd57043f396088
php
PHP
6
2016-09-26T02:09:06
True
False
True
Jun 05, 2012 at 03:50 AM
/api/public/snipt/40699/
sql-8
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a> <a href="#L-6">6</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="cp">&lt;?</span> </span><span id="L-2"><a name="L-2"></a><span class="nv">$GLOBALS</span><span class="p">[</span><span class="s1">&#39;DB&#39;</span><span class="p">]</span><span class="o">-&gt;</span><span class="na">DebugToFile</span> <span class="o">=</span> <span class="k">true</span><span class="p">;</span> </span><span id="L-3"><a name="L-3"></a><span class="c1">/// КОД ///</span> </span><span id="L-4"><a name="L-4"></a><span class="nv">$GLOBALS</span><span class="p">[</span><span class="s1">&#39;DB&#39;</span><span class="p">]</span><span class="o">-&gt;</span><span class="na">DebugToFile</span> <span class="o">=</span> <span class="k">false</span><span class="p">;</span> </span><span id="L-5"><a name="L-5"></a><span class="c1">// потом смотрим в /mysql_debug.php</span> </span><span id="L-6"><a name="L-6"></a><span class="cp">?&gt;</span><span class="x"></span> </span></pre></div> </td></tr></table>
bitrix

PHP

Определение нахождения в режиме редактирования

1
2
3
4
5
6
<?
if($APPLICATION->GetShowIncludeAreas())// true/false
{
    // режим редактирования включен
}
?>
https://snipt.net/embed/37e7f6076dfebb86eae85cd11a1ffd26/
https://snipt.net/raw/37e7f6076dfebb86eae85cd11a1ffd26/
37e7f6076dfebb86eae85cd11a1ffd26
php
PHP
6
2016-09-26T02:09:29
True
False
True
Jun 05, 2012 at 03:49 AM
/api/public/snipt/40698/
-205
<table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><a href="#L-1">1</a> <a href="#L-2">2</a> <a href="#L-3">3</a> <a href="#L-4">4</a> <a href="#L-5">5</a> <a href="#L-6">6</a></pre></div></td><td class="code"><div class="highlight"><pre><span id="L-1"><a name="L-1"></a><span class="cp">&lt;?</span> </span><span id="L-2"><a name="L-2"></a><span class="k">if</span><span class="p">(</span><span class="nv">$APPLICATION</span><span class="o">-&gt;</span><span class="na">GetShowIncludeAreas</span><span class="p">())</span><span class="c1">// true/false</span> </span><span id="L-3"><a name="L-3"></a><span class="p">{</span> </span><span id="L-4"><a name="L-4"></a> <span class="c1">// режим редактирования включен</span> </span><span id="L-5"><a name="L-5"></a><span class="p">}</span> </span><span id="L-6"><a name="L-6"></a><span class="cp">?&gt;</span><span class="x"></span> </span></pre></div> </td></tr></table>
bitrix
Copyrighted, illegal, or inappropriate content? Email support@snipt.net.