Архив

2015 год

Всего: 61 запись

ol, ul — цвет нумерации

article ul,article ol{
	list-style-type:none;
	counter-reset:num;
	margin:0 0 20px 0;
}
article ul li,article ol li{
	list-style-type:none;
	padding-left:20px;
	margin-bottom:4px;
}
article ul li:before,article ol li:before{
	color:#ffffff;
	background:#ff9300;
	border-radius:50%;
	padding:0 5px;
	text-align:center;
}
article ul li:before{
	content:"•";
}
article ol li:before{
	content:counter(num);
	counter-increment:num;
}

LESS:

.article{
	ul,ol{
		list-style-type:none;
		counter-reset:num;
		margin:0 0 20px 0;
		li{
			list-style-type:none;
			padding-left:20px;
			margin-bottom:4px;
			position:relative;
			&:before{
				position:absolute;
				top:0;
				left:0;
				color:@color_link;
				font-weight:600;
			}
		}
	}
	ul li:before{
		content:"•";
	}
	ol li:before{
		content:counter(num) ". ";
		counter-increment:num;
	}
}

Для того чтобы учитывался атрибут start у ol:

$('article ol').each(function(){
	var start=parseInt($(this).attr('start'));
	if(start>0){
		$(this).css('counter-reset','num '+(start-1));
	}
});

htaccess: Дубли страниц с несколькими слешами подряд в URL — также после домена

Усовершенствованное решение этого варианта: http://krylov.org.ua/?p=1130
.htaccess

RewriteCond %{REQUEST_URI} ^(.*)/{2,}(.*)$
RewriteRule . %1/%2 [R=301,L]

Работает для http://site.com/dir1///dir2
но проблема остается в адресах типа http://site.com///uri (несколько слешей после домена)
Решение на php:

if(stristr($_SERVER['REQUEST_URI'],'//')){
	$uri=preg_replace('#/{2,}#','/',$_SERVER['REQUEST_URI']);
	header('Location: '.$uri,false,301);
	exit;
}

form get убрать лишние параметры

В примере необходимо генерировать в URL фильтрацию по цене только в том случае, если пользователь сам изменил ползунок выбора цены.
Т.е. нужно не передавать определенные параметры в _GET (по ситуации).
Часть формы (добавляем hidden поля):

<form method="get" action="" id="filter_form">
	от <input type="text" name="price_from" id="price_from" value="100"/>
	до <input type="text" name="price_to" id="price_to" value="1000"/>
	<input type="hidden" id="price_min" value="100"/>
	<input type="hidden" id="price_max" value="1000"/>
</form>

Яваскриптом дисаблим inputы, если их значения не меняли.

$(function(){
	$("#filter_form").submit(function(){
		if($("#price_from").val()==$("#price_min").val()){
			$("#price_from").attr("disabled","disabled");
		}
		if($("#price_to").val()==$("#price_max").val()){
			$("#price_to").attr("disabled","disabled");
		}
	});
});