URL에서 % 26 및 % 3D를 제거하려면 어떻게해야합니까?

가격 (저가에서 고가, 고가에서 저가)별로 제품을 정렬하려는 경우 링크가 작동하지 않습니다. 옵션 값은 “price & product_list_dir = asc”이며 “price % 26product_list_dir % 3Dasc”로 인코딩됩니다. URL을 어떻게 디코딩 할 수 있나요?

코드는 다음과 같습니다.

<div class="toolbar-sorter sorter"> <label class="sorter-label" for="sorter"><?php /* @escapeNotVerified */ echo __("Sort by") ?></label> <select data-role="sorter" class="sorter-options selectpicker"> <?php $url = $_SERVER["REQUEST_URI"]; $path = strstr($url, "?"); ?> <option <?php if($path == "?product_list_order=price&product_list_dir=desc"): ?> selected="selected" <?php endif; ?> class="high-low" value="price&product_list_dir=desc"> Price - High to low </option> <option <?php if($path == "?product_list_order=price&product_list_dir=asc"): ?> selected="selected" <?php endif; ?> class="low-high" value="<?php /* @escapeNotVerified */ echo __("price&product_list_dir=asc") ?>"> Price - Low to high </option> </select></div> 

댓글

  • 무엇이 작동하지 않습니까? " 선택된 "가 제대로 에코되지 않습니까? html의 value 속성에 " % 26 및 % 3D "가 있으므로 < option value = " price % 26product_list_dir % 3Dasc " > '? 다른 유형의 정렬을 선택한 후에도 정렬 순서가 변경되지 않습니까? 더 빨리 도와 드릴 수 있도록 작동하지 않는 부분을 지정해주세요.
  • 요소 검사로 확인한 결과 옵션 값이 제대로 표시됩니다. 옵션을 클릭하면 mysite.com/category.html?product_list_order=price%26product_list_dir%3Dasc 페이지로 리디렉션됩니다. 하지만 " % 26 " 및 " % 3D 를 " & " 및 & " 주소 표시 줄에 직접 입력하면 작동합니다. 옵션을 클릭하면 Magento가 해당 옵션 값을 url로 인코딩하는 것 같습니다

Answer

It 예상대로 값을 올바르게 인코딩하는 “브라우저”입니다. 안전한 문자를 보려면 https://perishablepress.com/stop-using-unsafe-characters-in-urls/ 를 확인하세요.

제 생각에는 가장 좋은 방법입니다. 값을 “price $ product_list_dir! asc”또는 “price + dir-desc”또는 “price_desc”와 같이 설정하고 코드에서 product_list_order의 값을 구문 분석하는 것입니다. 기타 옵션은 다음과 같습니다.

  • 메뉴를 두 개의 드롭 다운 메뉴 (product_list_order 및 product_list_dir)로 분할
  • 풀다운 선택이 변경되면 javascript로 URL 업데이트

댓글

  • 감사합니다. onChange = " window.document.location.href = this.options [this.selectedIndex] .value; "를 추가하여 선택하고 < 스크립트 유형 = " 텍스트 / 자바 스크립트 " > jQuery (function ($) {$ (' select '). on (' 변경 ', function () {var url = $ (this) .val (); if (url) {window.location = url;} return false;} );}); < / script > 이제 ' 작동합니다. 감사합니다

답변

echo __("price&product_list_dir=asc")echo "price&product_list_dir=asc"

댓글

  • 도움을 주셔서 감사합니다. ' 작동하지 않음

답글 남기기

이메일 주소를 발행하지 않을 것입니다. 필수 항목은 *(으)로 표시합니다