Skip to content

Instantly share code, notes, and snippets.

@kay88
kay88 / Wordpress-SEO
Created September 12, 2016 11:53
Wordpress Title и метатеги без плагина
/** мета заголовок (title):
В function.php
------------------------------------- */
/** мета заголовок (title):
- Первый параметр функции это разделитель, второй название блога (если не указать берется из Настроек).
- Для меток и категорий указывается в настройках в описании (в настройках, по аналогии с пунком 6 Platinum SEO Pack, см. выше) так: [title=Заголовок]
- Для страниц или постов, если вы хотите чтобы заголовок страницы отличался от заголовка поста, то создайте произвольное поле title и впишите туда свое название
------------------------------------- */
function kama_meta_title ($sep=" | ",$bloginfo_name=''){
В файл function.php
//вывести первый тег em
function catch_that_em() {
global $post, $posts;
$first_em = '';
ob_start();
ob_end_clean();
$output = preg_match_all('#<[\s]*em[\s]*>([^<]*)<[\s]*/em[\s]*>#i', $post->post_content, $matches);
$first_em = $matches [1] [0];
@kay88
kay88 / script.js
Created September 5, 2016 09:38
modx-ajax-filter
$(function() {
//MODx pdoResources Ajax Filter
//Filter Settings
var fadeSpeed = 200, // Fade Animation Speed
ajaxCountSelector = '.ajax-count', // CSS Selector of Items Counter
ajaxContainerSelector = '.ajax-container', // CSS Selector of Ajax Container
ajaxItemSelector = '.ajax-item', // CSS Selector of Ajax Item
ajaxFormSelector = '.ajax-form', // CSS Selector of Ajax Filter Form
ajaxFormButtonStart = '.ajax-start', // CSS Selector of Button Start Filtering
@kay88
kay88 / catalogFilter.php
Created September 5, 2016 09:38
modx-ajax-filter
<?php
//Filter Fields Settings
$filter = array();
//Radio, Select & Text Fields Type
if($_GET['floor']) {
$filter[] = 'floor='.$_GET['floor'];
}
//Two Text Fields From To
if($_GET['area_from']) {
$filter[] = 'area>='.$_GET['area_from'];
@kay88
kay88 / script-min-Height
Created August 30, 2016 11:54
min-Height content + "- height" js
<script type="text/javascript">
jQuery(document).ready(function ($) {
function contentHeight(){
$('.b-content__bg').css('min-height', ($(window).height()-261)+'px');
}
contentHeight();
$(window).resize(function () {
contentHeight();
});
});
<?php
$today = date("Y-n-j");
$tv = $modx->resource->getTVValue('event_name');
$ret = '{"publishedon:>=":"'.strtotime("$today 00:00:00").'"}';
return $ret;
------------------------------------------------------------------
[[!getResources?
&showHidden=`1`
&tpl=`item-doing`
<?php
$tvid = 1; // id ТВ с датой
$date = date('Y-m-d'); // Сегодня
$q = $modx->newQuery('modResource');
$q->leftJoin('modTemplateVarResource', 'TV', 'modResource.id = TV.contentid AND TV.tmplvarid = '.$tvid);
$q->select('modResource.id');
$q->where('DATE(TV.value) = "'.$date.'"');
if ($q->prepare() && $q->stmt->execute()) {
@kay88
kay88 / switchlang
Last active July 8, 2016 05:50
Plug-in language
<?php
if (preg_match("#\/[a-z]{2}#", $_SERVER['REQUEST_URI'], $matches)){
$lankey = trim($matches[0], '/');
}else{
$lankey = 'ru';
}
if($modx->context->get('key') != "mgr") {
@kay88
kay88 / ifgetresources if
Created July 8, 2016 05:42
ifgetresources if >id
<?php
$post_content = '';
$parenttwo = 29;
$id = $modx->resource->id;
if ($parenttwo > $id)
{
echo $post_content = '
@kay88
kay88 / ifgetresources
Created April 28, 2016 11:03
MODX snippet IF по ID getResources
<!-- Вызов сниппета-->
[[ifgetresources]]
<!-- Вызов сниппета-->
<?php
$post_content = '';
$parent = $modx->resource->id;
switch($parent){