currentPageId (function)

Last updated: Mon, Apr 17, 2023 7:20 am
Return to Knowledgebase

Purpose

Retrievse the ID of the current page based on the URI

Location

users/helpers/deprecated.php

Parameters

# Parameter Data Type Required Description
1 $uri string Yes The URI is passed to the function as a parameter, and it is used to identify the corresponding page in the database.

Returns

Data Type Description of Returned Data
int Returns an integer value, which represents the ID of the current page in the database. If the function fails to find a matching page, it returns 0.

Further Documentation:

The currentPageId() function is a custom function in the UserSpice PHP framework, which is used to retrieve the ID of the current page based on the URI. This function takes a URI as its parameter, and then it searches for the corresponding page in the database. If it finds a matching page, it returns its ID; otherwise, it returns 0.

Here's an example of how you can use this function:


// Include UserSpice
require_once 'users/init.php';

// Get the ID of the current page
$pageId = currentPageId($_SERVER['REQUEST_URI']);

// Use the page ID for something
echo "The ID of the current page is: " . $pageId;
?>