Перейти к содержанию
Официальный форум поддержки Simpla

Рекомендуемые сообщения

Я вставил коды в products.tpl :

в самом начале:

{* Список товаров *}
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.2/jquery-ui.js"></script>
<link rel="stylesheet" href="design/{$settings->theme|escape}/css/slider-filt.css" />

<script type="text/javascript">
	$(document).ready(function() {
		var minprice = parseInt($('#minprice').val());
		var maxprice = parseInt($('#maxprice').val());

		var current_minprice = parseInt($('#current_minprice').val());
		var current_maxprice = parseInt($('#current_maxprice').val());
		$("input#minCost").val(current_minprice);
		$("input#maxCost").val(current_maxprice);
		$("#slider").slider({
		    min: minprice,
		    max: maxprice,
		    values: [current_minprice,current_maxprice],
		    range: true,
		    slide: function(event, ui){
				$("input#minCost").val($("#slider").slider("values",0));
				$("input#maxCost").val($("#slider").slider("values",1));
		    }
		});
	});

	
</script>

и там где будет отображаться фильтр:

{* Сортировка *}
{if $products|count>0}
<div class="sort">
	Сортировать по 
	<a {if $sort=='position'} class="selected"{/if} href="{url sort=position page=null}">умолчанию</a>/
	<a {if $sort=='price'}    class="selected"{/if} href="{url sort=price page=null}">цене</a>/
	<a {if $sort=='name'}     class="selected"{/if} href="{url sort=name page=null}">названию</a>/
    
    <div id="slider-filtr">
    <input type="hidden" value="{$minprice}" id="minprice">
    <input type="hidden" value="{$maxprice}" id="maxprice">
    <input type="hidden" value="{$current_minprice}" id="current_minprice">
    <input type="hidden" value="{$current_maxprice}" id="current_maxprice">
    
    <form method="post">
    <div class="cena">от:</div>
    <input type="text" class="slider-input" name="min_price" id="minCost" />
    <div id="slider"></div>
    <div class="cena">до:</div><input type="text" class="slider-input" name="max_price" id="maxCost">
    <div class="cena"><span class="currency">{$currency->sign|escape}</span> </div><input type="submit" class="slider-submit" value="Применить">
    </form>
    </div>
</div>
{/if}

а в css-папку закинул вот этот файл: slider-filtr.css

Ссылка на сообщение
Поделиться на другие сайты
  • Ответов 124
  • Дата создания
  • Последний ответ

Лучшие авторы в теме

Лучшие авторы в теме

Изображения в теме

Я вставил коды в products.tpl :

в самом начале:

{* Список товаров *}
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.2/jquery-ui.js"></script>
<link rel="stylesheet" href="design/{$settings->theme|escape}/css/slider-filt.css" />

<script type="text/javascript">
	$(document).ready(function() {
		var minprice = parseInt($('#minprice').val());
		var maxprice = parseInt($('#maxprice').val());

		var current_minprice = parseInt($('#current_minprice').val());
		var current_maxprice = parseInt($('#current_maxprice').val());
		$("input#minCost").val(current_minprice);
		$("input#maxCost").val(current_maxprice);
		$("#slider").slider({
		    min: minprice,
		    max: maxprice,
		    values: [current_minprice,current_maxprice],
		    range: true,
		    slide: function(event, ui){
				$("input#minCost").val($("#slider").slider("values",0));
				$("input#maxCost").val($("#slider").slider("values",1));
		    }
		});
	});

	
</script>

и там где будет отображаться фильтр:

{* Сортировка *}
{if $products|count>0}
<div class="sort">
	Сортировать по 
	<a {if $sort=='position'} class="selected"{/if} href="{url sort=position page=null}">умолчанию</a>/
	<a {if $sort=='price'}    class="selected"{/if} href="{url sort=price page=null}">цене</a>/
	<a {if $sort=='name'}     class="selected"{/if} href="{url sort=name page=null}">названию</a>/
    
    <div id="slider-filtr">
    <input type="hidden" value="{$minprice}" id="minprice">
    <input type="hidden" value="{$maxprice}" id="maxprice">
    <input type="hidden" value="{$current_minprice}" id="current_minprice">
    <input type="hidden" value="{$current_maxprice}" id="current_maxprice">
    
    <form method="post">
    <div class="cena">от:</div>
    <input type="text" class="slider-input" name="min_price" id="minCost" />
    <div id="slider"></div>
    <div class="cena">до:</div><input type="text" class="slider-input" name="max_price" id="maxCost">
    <div class="cena"><span class="currency">{$currency->sign|escape}</span> </div><input type="submit" class="slider-submit" value="Применить">
    </form>
    </div>
</div>
{/if}

а в css-папку закинул вот этот файл: slider-filtr.css

Вот спасибо большое! Помогло :)

Ссылка на сообщение
Поделиться на другие сайты

 

DarAmal, все, разобрался. Просто слайдер от Noxton'a конфликтовал с этим слайдером цен. js конфликтовали. 

Ссылка на сообщение
Поделиться на другие сайты

Можно ли реализовать? На главной стоит обычный поиск а справа фильтр цен....

к примеру в поиск вбиваешь HTC и выставляешь ценовой диапазон и жмякаешь применить....и выдается соответсвующая инфа! типа HTC от 1700-5000 руб

Ссылка на сообщение
Поделиться на другие сайты

Добрый день. Слайдер установил, работает, автору спасибо. Только вот если зайти в категорию, где товаров нет или еще не заполнены, вылезает следующая ошибка:

 

 

Warning: Wrong parameter count for min() in .../view/ProductsView.php on line 206

Warning: Wrong parameter count for max() in .../view/ProductsView.php on line 207

Warning: Cannot modify header information - headers already sent by (output started at ...l/view/ProductsView.php:206) in .../index.php on line 33

 

 

ProductsView.php


$min_price = 0;
$max_price = 0;
$min_price = min($prices);
$max_price = max($prices);

 

 

 

index.php

// Выводим результат
    header("Content-type: text/html; charset=UTF-8");    
    print $res;

 

Буду крайне благодарен за помощь в устранении ошибки.

Ссылка на сообщение
Поделиться на другие сайты

До сих пор выводит запись NaN. С чем может быть связано??

Уже все перепроверил, как только мог.

У меня такое же было. И это оказалось из-за версии. Ранее была версия 2.1.0.. но после обновления до 2.2 все стало нормально отображаться. Мой Вам совет, с начало обновитесь.

Ссылка на сообщение
Поделиться на другие сайты

После того, как синхронизировал с 1с или перенес на новый хостинг слайдер стал вести себя оч. странно: если кликаешь по ползунку, цена обновляется не сразу и может меняться хоть в большую хоть в меньшую сторону, хотя кликаешь правее… попытался объяснить)

+делаешь выборку, переходишь на следующую страницу с товаром и выборка пропадает

 

в чем может быть проблема? передобавил слайдер заново, поведение не изменилось

Ссылка на сообщение
Поделиться на другие сайты

ДД! Такая же ситуация, пытаюсь вывести сортировку по цене на главной странице.

 

В index.tpl вставил все что надо. Сам код + скрипт js + подключил jquery + стили + вставил саму форму:

<div class="sort">
	Сортировать по 
	<a {if $sort=='position'} class="selected"{/if} href="{url sort=position page=null}">умолчанию</a>/
	<a {if $sort=='price'}    class="selected"{/if} href="{url sort=price page=null}">цене</a>/
	<a {if $sort=='name'}     class="selected"{/if} href="{url sort=name page=null}">названию</a>/
    
    <div id="slider-filtr">
    <input type="hidden" value="{$minprice}" id="minprice">
    <input type="hidden" value="{$maxprice}" id="maxprice">
    <input type="hidden" value="{$current_minprice}" id="current_minprice">
    <input type="hidden" value="{$current_maxprice}" id="current_maxprice">
    
    <form method="post">
    <div class="cena">от:</div>
    <input type="text" class="slider-input" name="min_price" id="minCost" />
    <div id="slider"></div>
    <div class="cena">до:</div><input type="text" class="slider-input" name="max_price" id="maxCost">
    <div class="cena"><span class="currency">{$currency->sign|escape}</span> </div><input type="submit" class="slider-submit" value="Применить">
    </form>
    </div>
</div>

+ еще в MainView.php сделал следующее:

<?PHP

require_once('View.php');


class MainView extends View
{

	function fetch()
	{
		$current_min_price = $this->request->post('min_price');
		$current_max_price = $this->request->post('max_price');
		
		$filter = array();
		$filter['visible'] = 1;	

		$filter['min_price'] = $current_min_price;
		$filter['max_price'] = $current_max_price;
		
		
		if($this->page)
		{
			$this->design->assign('meta_title', $this->page->meta_title);
			$this->design->assign('meta_keywords', $this->page->meta_keywords);
			$this->design->assign('meta_description', $this->page->meta_description);
		}

		
		unset($filter['min_price']);
		unset($filter['max_price']);
		unset($filter['limit']);
		foreach($this->products->get_products($filter) as $p)
			$products_prices[$p->id] = $p;
		
		if(!empty($products_prices))
		{
			$prices_products_ids = array_keys($products_prices);
			$prices_variants = $this->variants->get_variants(array('product_id'=>$prices_products_ids));
			foreach($prices_variants as &$prices_variant)
				$prices[] = $prices_variant->price;
		}
		
		$min_price = 0;
		$max_price = 0;
		$min_price = min($prices);
		$max_price = max($prices);
		
		if(!isset($current_min_price) && empty($current_min_price))
			$current_min_price = $min_price;
		if(!isset($current_max_price) && empty($current_max_price))
			$current_max_price = $max_price;
			
		$this->design->assign('minprice', $min_price);
		$this->design->assign('maxprice', $max_price);
		$this->design->assign('current_minprice', $current_min_price);
		$this->design->assign('current_maxprice', $current_max_price);
		
		return $this->design->fetch('main.tpl');
	}
}

Так вот цену он в поля заполняет! А вот сортировку по кнопке применить не делает! В чем проблема?!

Ссылка на сообщение
Поделиться на другие сайты

Судя по этому коду, то выбор товаров для вывода у вас в принципе не происходит, только для определения минимальной и максимальной цен

Ссылка на сообщение
Поделиться на другие сайты

Идиотека в голове 

Parse error: syntax error, unexpected T_REQUIRE_ONCE in /home/godrivec/public_html/api/Products.php on line 1

Все ввожу по инструкции 100%

делаю каждый шаг 

в итоге эта ошибка

Автор можешь помочь? Насыплю пару баксов только укажи ошибку ?

Ссылка на сообщение
Поделиться на другие сайты

Я как бы руками ничего не делал, все по инструкции, скопировал вставил %)

Кто то может помочь с установкой ? 

 

кавычки забыли где то закрыть

Ссылка на сообщение
Поделиться на другие сайты

VladP

Разобрался

Вначале были ошибки в products.php  взял файл который был в вашем архиве

Но заметил не корректную работу фильтра

Например захожу в подкатегорию планшеты, у меня их на 2 листа, выставляю диапазон цен, в итоге фильтр отсеивает только те которые на первой странице, вторую страницу не трогает

заходишь на вторую - опять фильтруешь смысла тот же, фильтрует только на текущей странице.

 

 

Добавлено :

 

+ заметил что в разных подкатегориях ведет себя по разному, например видеорегистраторы работает корректно

Бытовая техника вообще не работает

 

Телефоны частично

 

Планшеты как описано выше что только на текущей странице

 

Могу выложить файлы что я редактировал

 

 

 

Делал по инструкции частично:

вначале отредактировал products.php

productsview.php

index.tpl - вставил java скрипт

хотел сначала реализовать на главное этот фильтр, после понял что он там не нужен

засунул

 

код по подсказке DarAmal

в products.tpl





{* Список товаров *}
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>
<script src="http://code.jquery.com/ui/1.10.2/jquery-ui.js"></script>
<link rel="stylesheet" href="design/{$settings->theme|escape}/css/slider-filt.css" />

<script type="text/javascript">
	$(document).ready(function() {
		var minprice = parseInt($('#minprice').val());
		var maxprice = parseInt($('#maxprice').val());

		var current_minprice = parseInt($('#current_minprice').val());
		var current_maxprice = parseInt($('#current_maxprice').val());
		$("input#minCost").val(current_minprice);
		$("input#maxCost").val(current_maxprice);
		$("#slider").slider({
		    min: minprice,
		    max: maxprice,
		    values: [current_minprice,current_maxprice],
		    range: true,
		    slide: function(event, ui){
				$("input#minCost").val($("#slider").slider("values",0));
				$("input#maxCost").val($("#slider").slider("values",1));
		    }
		});
	});

	
</script>

и там где будет отображаться фильтр





{* Сортировка *}
{if $products|count>0}
<div class="sort">
	Сортировать по 
	<a {if $sort=='position'} class="selected"{/if} href="{url sort=position page=null}">умолчанию</a>/
	<a {if $sort=='price'}    class="selected"{/if} href="{url sort=price page=null}">цене</a>/
	<a {if $sort=='name'}     class="selected"{/if} href="{url sort=name page=null}">названию</a>/
    
    <div id="slider-filtr">
    <input type="hidden" value="{$minprice}" id="minprice">
    <input type="hidden" value="{$maxprice}" id="maxprice">
    <input type="hidden" value="{$current_minprice}" id="current_minprice">
    <input type="hidden" value="{$current_maxprice}" id="current_maxprice">
    
    <form method="post">
    <div class="cena">от:</div>
    <input type="text" class="slider-input" name="min_price" id="minCost" />
    <div id="slider"></div>
    <div class="cena">до:</div><input type="text" class="slider-input" name="max_price" id="maxCost">
    <div class="cena"><span class="currency">{$currency->sign|escape}</span> </div><input type="submit" class="slider-submit" value="Применить">
    </form>
    </div>
</div>
{/if}

 

а в css-папку закинул вот этот файл: slider-filtr.css

 

 

Итог фильтр отображается, красиво с ползунком в отличном стиле, но работает не корректно

Ссылка на сообщение
Поделиться на другие сайты

Ага, нужно хранить в куках или передавать не через POST, а GET

попробуйте в <form method="post"> убрать method="post",

 

$current_min_price = $this->request->post('min_price');
$current_max_price = $this->request->post('max_price');

 

заменить на 

 

$current_min_price = $this->request->get('min_price');

$current_max_price = $this->request->get('max_price');

 

 

если не поможет, завтра покажу как с куками сделать

Ссылка на сообщение
Поделиться на другие сайты
  • 4 недели спустя...

А как побороть ситуацию, когда товар уже отфильтрован и его на несколько страниц и при переходе на следующую страницу параметры диапазона цен в фильтре сбрасываются и нужно заново их вводить?

Ссылка на сообщение
Поделиться на другие сайты

Присоединяйтесь к обсуждению

Вы можете написать сейчас и зарегистрироваться позже. Если у вас есть аккаунт, авторизуйтесь, чтобы опубликовать от имени своего аккаунта.

Гость
Ответить в этой теме...

×   Вставлено с форматированием.   Вставить как обычный текст

  Разрешено использовать не более 75 эмодзи.

×   Ваша ссылка была автоматически встроена.   Отображать как обычную ссылку

×   Ваш предыдущий контент был восстановлен.   Очистить редактор

×   Вы не можете вставлять изображения напрямую. Загружайте или вставляйте изображения по ссылке.

Загрузка...

×
×
  • Создать...