Skip to content

Instantly share code, notes, and snippets.

View Edarlingen's full-sized avatar

Aleksey Karagodnikov Edarlingen

  • Russian Federation
View GitHub Profile
@Edarlingen
Edarlingen / function.inc.php
Last active February 27, 2023 19:49
Рекурсивное построение меню сайта в NetCat
<?php
/**
* Использование в макетах дизайна/врезках/компонентах: <?= buildMenu(); ?>
* Будет сформирован обычный маркированный список без классов, кроме классов с отображением состояния раздела у li.
* Внимательно читайте описание функций. Их необходимо разместить в файле /netcat/modules/default/function.inc.php
*/
/**
* Функция для определения классов для указанного раздела
* @param int $given_sub - номер раздела
@Edarlingen
Edarlingen / function.inc.php
Last active November 13, 2020 15:56
Использование шорткодов в NetCat
<?php
// Файл: /netcat/modules/default/function.inc.php
// Регистрируем шаблон вида %NC_GALLERY_SHOW($args)% в качестве макропеременной (или шорткода, для ясности)
// Его параметры, записанные вот так: %NC_GALLERY_SHOW(1, 2)% будут переданы в качестве аргументов в функцию show_gallery
nc_Core::get_object()->register_macrofunc('NC_GALLERY_SHOW', 'show_gallery');
// Определяем простую функцию, обрабатывающую такой "шорткод". Проверка аргументов опущена для краткости
function show_gallery($sub, $cc) {
@Edarlingen
Edarlingen / nginx.conf
Created April 10, 2017 06:35
nginx: if-modified-since
location @fallback {
proxy_pass http://127.0.0.1:8080;
proxy_redirect http://127.0.0.1:8080 /;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header If-Modified-Since $http_if_modified_since;
access_log off ;
}
@Edarlingen
Edarlingen / nginx.conf
Created April 10, 2017 06:33
nginx: кэш
location ~ ^.+\.(css|txt|js)$ {
root $root_path;
gzip_static on;
access_log off; # не пишем логи
add_header Cache-Control public;
expires 7d; # кешируем у клиента на 7 дней
add_header ETag "";
}
location ~ ^.+\.(jpg|jpeg|gif|png|ico|pdf|ppt|bmp|js)$ {
@Edarlingen
Edarlingen / .htaccess
Created April 5, 2017 11:45
Шаблон для оптимизации
<IfModule mod_deflate.c>
#The following line is enough for .js and .css
AddOutputFilter DEFLATE js css
AddOutputFilterByType DEFLATE text/plain text/xml application/xhtml+xml text/css application/xml application/rss+xml application/atom_xml application/x-javascript application/x-httpd-php application/x-httpd-fastphp text/html
#The following lines are to avoid bugs with some browsers
BrowserMatch ^Mozilla/4 gzip-only-text/html
BrowserMatch ^Mozilla/4\.0[678] no-gzip
BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
@Edarlingen
Edarlingen / isp-update.sh
Created March 2, 2017 11:47
Обновление ISP Manager
/usr/local/mgr5/sbin/licctl fetch ispmgr
/usr/local/mgr5/sbin/pkgupgrade.sh coremanager
@Edarlingen
Edarlingen / prefix.php
Last active November 12, 2020 21:02
Использование дополнительных шаблонов внутри компонента
<?
// Имя дополнительного шаблона
$partial_template_name = 'Test';
// Данные для передачи в дополнительный шаблон
$data = array('example' => 'string');
// Переменная с набором свойств текущего шаблона
global $template_env;
// Функция определяет корневой родительский шаблон для указанного шаблона
@Edarlingen
Edarlingen / gist:d63b413fc765a8fcae0f8ef3e773b4d9
Created August 20, 2016 21:56 — forked from lttlrck/gist:9628955
rename git branch locally and remotely
git branch -m old_branch new_branch # Rename branch locally
git push origin :old_branch # Delete the old branch
git push --set-upstream origin new_branch # Push the new branch, set local branch to track the new remote
@Edarlingen
Edarlingen / breadcrumbs.php
Last active May 22, 2024 11:08
Хлебные крошки в Netcat.
<?php
$url = $nc_core->catalogue->get_url_by_id($catalogue);
$full_url_without_query = $url . $nc_core->url->get_parsed_url('path');
$h1 = $nc_core->page->get_h1();
$breadcrumb_position = 1;
$current_cc_subdivision_id = $current_cc['Subdivision_ID'] ?: 0;
?>
<ol class='breadcrumb' itemscope='' itemtype='https://schema.org/BreadcrumbList'>
@Edarlingen
Edarlingen / function.inc.php
Last active November 12, 2020 21:02
Установка Title в NetCat
<?php
function get_seo_title($title_delimeter = ' :: ') {
global $parent_sub_tree;
global $current_sub;
global $current_cc;
global $action;
global $message;
global $title_tail;
$nc_core = nc_Core::get_object();