B
B
bichukov2022-03-21 17:36:22
1C-Bitrix
bichukov, 2022-03-21 17:36:22

Why might the request not be displayed in the url string?

Good afternoon, there was such a difficulty.
There is such a code

<?
        $GLOBALS['arrFilter1'] = array("PROPERTY_YAVLYAETSI_VALUE"=>"новинкой");
        $GLOBALS['arrFilter2'] = array("PROPERTY_YAVLYAETSI_VALUE"=>"популярным");
        $GLOBALS['arrFilter3'] = array("PROPERTY_YAVLYAETSI_VALUE"=>"акцией");


        if ($_GET["sort"] == "price")
        {
            $arParams["ELEMENT_SORT_FIELD"] = "SCALED_PRICE_1";
        }

        switch ($_GET["order"]) {
            case "new":
                $arParams["FILTER_NAME"]= "arrFilter1";
                break;
            case "hit":
                $arParams["FILTER_NAME"]= "arrFilter2";
                break;
            case "sale":
                $arParams["FILTER_NAME"]= "arrFilter3";
                break;
            case "vozvr":
                $arParams["ELEMENT_SORT_ORDER"]= "asc" ;
                break;
            case "ubiv":
                $arParams["ELEMENT_SORT_ORDER"]= "desc" ;
                break;
            case "popular":
                $arParams["ELEMENT_SORT_ORDER"]= "shows" ;
                break;
        }

        ?>

        <?
        if ($_GET["order"]=='new')
        {
         $href=$APPLICATION->GetCurPageParam("", array("?order"));
        }
        elseif($_GET["order"]=='')
        {
            $href=$APPLICATION->GetCurPageParam("order=new");
        }

        ?>


So, $APPLICATION->GetCurPageParam when using it, in theory, should be displayed in the url of the get request, but it is empty there, but the sorting works.
those. now it's like this ...catalog/ but it should be like this /catalog/?order=new
Tell me where I did something wrong?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
R
regsmic, 2022-03-21
@regsmic

Most likely nginx or apache removes no requests from uri.

S
Sergey, 2022-03-22
@Firsov36

Your code has been taken out of context. Most likely, you are still using some component. Displaying a list of products / sections with the ability to sort this list? Most likely this component uses the entry of the selected sort in $_SESSION or cookies and the values ​​are used from there, so you have

but sorting works
.
And I didn't really understand the phrase
So, $APPLICATION->GetCurPageParam when using it, in theory, should be displayed in the url of the get request, but it is empty there

but if I understood correctly, then just my guess earlier explains this behavior: the values ​​​​from the previously stored values ​​\u200b\u200bin the session / cookies are used, but an empty get-request.
And your code does not work correctly, because the error is in using the function:
$APPLICATION->GetCurPageParam("", array("?order"));

The second parameter must contain an array of variables to remove. There is no such thing as a variable like "?order", you need to write it without "?", just an array of get request keys.
Here's a test you can try. Create a page on the site and run, for example, site.ru/test.php?order=new and you will see what kind of leapfrog it turns out if the function parameters are not used correctly.
<?php
require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/prolog_before.php");

/**
 * @global CMain $APPLICATION
 */

var_dump($APPLICATION->GetCurPageParam());
var_dump($APPLICATION->GetCurPageParam("", ["?order"]));
var_dump($APPLICATION->GetCurPageParam("", ["order"]));
var_dump($APPLICATION->GetCurPageParam("order=new"));

require($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/main/include/epilog_after.php");

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question