Developer's Manual  Function Reference  Functions to work with content tables  suPathById

suPathById

Returns page path of given page(s).


mixed suPathById
(mixed page_id [, string table_name])

The function returns path as a string or paths as an array of stings with the page ids as the array keys. The type of return value depends on page_id format. You can specify page_id in one of the following formats:

  • as a number
  • as an array of page id
  • as a string
By default, current content table is used or you can specify table name to get paths from. Failure to specify correct table name will cause fatal error.

The function returns FALSE if no page found for given id. Or returns an empty array if no pages was found.

<?
$path
= suPathById(75);
echo
"Page path: " . $path;
// This will print
// Page path: /dev/reference/database/

$paths = Array(75, 175, 67);
$path = suPathById($paths);
print_r($path);

$paths = '75,175,67';
$path = suPathById($paths);
print_r($path);

/*
The output of print_r($path) will be:
Array
(
    [67] => /dev/reference/database/
    [75] => /dev/reference/content/supathbyid/
    [175] => /dev/whatnew/
)
*/
?>
Please login to add comments.