Documentation

GetCurPageParam

string
 CMain::GetCurPageParam(
  string add_params = "",
  array remove_params = array(),
  bool get_index_page = null
)

The method returns the path and name of the current page relative to the site root and optionally modifies (adds or removes) the URL parameters. Non-static method.

If the file of the current page is not defined explicitly, the index page of a folder is determined using the algorithm of the GetDirIndex function.

Method's functions are performed by methods in the new core:

Parameters

ParameterDescription Available from version
add_paramsString containing parameters to be added to the returned string.
Optional parameter. The default value is an empty string..
remove_params Array with parameters to be removed from the page URL.
Optional parameter. The default value is an empty array.
get_index_pageParameter specifies to return path ending on "index.php" for the index page. If set to true, the path with "index.php", is returned. Otherwise, the path ending with "/" is returned. By default value - null.

If get_index_page is set as:

  • null - the behaviour is determined by the BX_DISABLE_INDEX_PAGE constant. If the constant value is true, the default value for the parameter get_index_page=false.
  • false - index.php is deleted from the returned URL (substring from the "0" position to the first encountered "/index.php" is returned)
  • true - URL will return without modifications

See Also

Examples of use

<?
// current page: /en/?id=3&s=5&d=34
$page = $APPLICATION->GetCurPageParam("id=45", array("id", "d")); 
// result - /en/index.php?id=45&s=5
?>
// example of created links for "Logout" and "Registration"

<?if ($USER->IsAuthorized()):?>

 <a href="<?echo $APPLICATION->GetCurPageParam("logout=yes", array(
     "login",
     "logout",
     "register",
     "forgot_password",
     "change_password"));?>">Finish session (logout)</a>

<?else:?>
 
 <a href="<?echo $APPLICATION->GetCurPageParam("register=yes", array(
     "login",
     "logout",
     "forgot_password",
     "change_password"));?>">Registration</a>

<?endif;?>

If the parameter logout=yes didn't result in logoutF, add session ID bitrix_sessid_get(). Result:

Code
<a href="GetCurPageParam("logout=yes&".bitrix_sessid_get(), array(
      "login",
      "logout",
      "register",
      "forgot_password",
      "change_password"));?>">Finish session (logout)


© «Bitrix24», 2001-2024
Up