This file contains hidden or 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
Использоватние | |
{$variable | snippet} | |
Сниппет "snippet" | |
<?php | |
/** @var modX $modx */ | |
switch ($modx->event->name) { | |
case 'pdoToolsOnFenomInit': | |
/** @var Fenom $fenom | |
Мы получаем переменную $fenom при его первой инициализации и можем вызывать его методы. |
This file contains hidden or 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
sudo find /path/ -type f -exec chmod 644 {} \; && sudo find /path/ -type d -exec chmod 755 {} \; |
This file contains hidden or 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
Смена прав только у директорий (рекурсивно) | |
$ find /path/to/base/dir -type d -exec chmod 755 {} + | |
или | |
$ chmod 755 $(find /path/to/base/dir -type d) | |
или | |
$ chmod 755 `find /path/to/base/dir -type d` | |
или | |
$ find /path/to/base/dir -type d -print0 | xargs -0 chmod 755 | |
Смена прав только у файлов (рекурсивно) |
This file contains hidden or 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
sudo apt-get update && sudo apt-get upgrade | |
sudo apt-get install curl | |
sudo apt-get install software-properties-common | |
sudo apt-get install python-software-properties | |
sudo apt-get install language-pack-ru-base | |
sudo echo "ru_RU.CP1251 CP1251" >>/var/lib/locales/supported.d/ru | |
sudo locale-gen | |
sudo locale-gen en_US.UTF-8 | |
export LANG=en_US.UTF-8 | |
export LANG=C.UTF-8 |
This file contains hidden or 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
Выборка из масива Тип поля в БД должен быть json | |
В поле хранится по типу [one,two,three,four,five] | |
SELECT * FROM `table_name` WHERE JSON_CONTAINS(`field`,'[value]'); | |
В поле хранится по типу ID ТАБЛИЦЫ 1 - ["one","two","three","four","five"] | |
SELECT * FROM `table_name` WHERE JSON_CONTAINS(`field`,'['\"value\"']'); | |
SELECT * FROM `table_name` WHERE JSON_CONTAINS(`field`,JSON_ARRAY('value')); | |
SELECT JSON_EXTRACT((SELECT `field` FROM `table_name` WHERE `id` = 1),'$[index]') as title; |
This file contains hidden or 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
$options = array(); | |
$translit = $modx->getOption('friendly_alias_translit', $options, 'russian'); | |
$translitClass = $modx->getOption('friendly_alias_translit_class', $options, 'translit.modTransliterate'); | |
$translitClassPath = $modx->getOption('friendly_alias_translit_class_path', $options, $modx->getOption('core_path', $options, MODX_CORE_PATH) . 'components/'); | |
$modx->getService('translit', $translitClass, $translitClassPath, $options); | |
$transliteratedtext = $modx->translit->translate($text, $translit); |
This file contains hidden or 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
Если перед вами стоит задача написать компонент для MODX Revolution, выбирающий некие данные из БД и отображающий их, то с большой долей вероятности вам потребуется добавить постраничную навигацию. | |
Для MODX Revolution существует отличное дополнение getPage с широкими возможностями, которое превосходно справляется с этой задачей. От вас потребуется совсем немного, что бы подружить ваш компонент с getPage и заставить работать их в связке. | |
Немного о getPage | |
getPage - это вспомогательный сниппет, который служит для реализации постраничной навигации на сайте и является своеобразной "оберткой" для других сниппетов. | |
Установочный пакет в репозитории: http://modx.com/extras/package/getPage | |
Официальная документация: http://rtfm.modx.com/display/ADDON/getPage | |
Как работает getPage? |
This file contains hidden or 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
Суть проблемы | |
Во время сохранения ресурса значения TV-параметров не сохраняются в таблице базы данных (modx_site_tmplvar_contentvalues), при этом внешне всё выглядит нормально: после сохранения в соответствующих полях отображаются обновлённые значения. Однако после перезагрузки страницы редактирования поля вновь оказываются пустыми (или заполненными значениями по умолчанию). | |
В файле error.log системы (раздел Управление→Отчёты→Журнал ошибок административной панели) отображается следующее сообщение об ошибке: | |
[2016-10-19 08:18:19] (ERROR @ /var/www/init/www/core/xpdo/om/xpdoobject.class.php : 240) Error HY000 executing statement: | |
Array | |
( | |
[0] => HY000 | |
[1] => 3065 |
This file contains hidden or 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 sortCatalog(products, section, reverse = false) { | |
// Переменные | |
var arProductsList = []; | |
var strHtml = ''; | |
// Переделываем в массив | |
products.each(function (e) { | |
arProductsList.push(products[e]); | |
}); |
This file contains hidden or 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
Фото должно быть по пути | |
assets/components/minishop2 | |
assets/components/ms2gallery | |
{"small":{"w":344,"h":552,"q":100,"zc":"0","far":"C","f":"png","bg":"ffffff","fltr":"wmi|ico-infographic-03.png|BR|50|5|5"},"small_ex":{"w":285,"h":285,"q":100,"zc":"0","far":"C","f":"png","bg":"ffffff","fltr":"wmi|ico-infographic-03.png|C | |
|50|5|5"}} |