Need to know how to make additions to the address bar on this site .

> А конкретнее при выборе интервале цены появляется > ..../?price=16200-36729... далее если в окне с товаром выбираем > допустим вид отображения,теперь ссылка > такая..../price=22188-39936&viewmode=list а если еще выбрать > "сортировать по " уже такая > .../price=22188-39936&viewmode=list&orderby=11 

Someone tell me how to implement such an addition?

  • If you are given an exhaustive answer, mark it as correct (a daw opposite the selected answer). - Nicolas Chabanovsky
  • When I click on a link that sends a request to GET, I set a condition if parameters come from a link that I need to read them using foreach and make variables for <input type = "hidden"> which is in a form (which is a filter). filter pass filter parameters as well as what was already in the GET. If there is already a filter and when I click on the link (in my case, the link is sorting by price) I read the same GET method to make such a variable `$ link. =" & "; $ link. = $ key. = "="; $ link. = $ value; `and put in <a href="&price=desc$link"> Sort by price </a> - Dashkevich Sergey
  • I can later make a file with explanations if anyone needs it - Dashkevich Sergey

2 answers 2

I was also tormented the other day with a similar question, I did not find an exact solution, but they suggested something useful, in principle, in my case, it could be useful to you, too. I have 2 filters on my page, I also wanted to add a URL depending on the activated filter. I’ll drop the code to you.

 function queryStringBuilder(id) { var paramsId = id; this.getQueryString = function() { var queryString = []; for (var i = 0; i < paramsId.length; i++) { var elem = $(paramsId[i]); if (elem.val().trim()) queryString.push((elem.attr('id') || elem.attr('name')) + "=" + escape(elem.val())); } return queryString.join("&"); } } var queryBuilder = new queryStringBuilder(['#dep-id', '#month']); function showQueryString(value) { location.search = value; } $('#dep-id').change(function() { showQueryString(queryBuilder.getQueryString()); }); $('#month').change(function() { showQueryString(queryBuilder.getQueryString()); }); 
  • Thank you, at least I haven’t yet mastered JS. I'll try to learn it by typing, and at that time PHP will be able to resolve resources - Dashkevich Sergey

Use the HTML5 History API

Article: https://habrahabr.ru/post/123106/

Example:

 history.pushState({foo: 'bar'}, "page 2", "/my/custom/path"); 

Documentation: https://developer.mozilla.org/ru/docs/Web/API/History_API

  • Please try to publish detailed answers containing a specific example of the minimum solution, supplementing them with a link to the source. Answers –references (like comments) do not add knowledge to Runet. - Nicolas Chabanovsky