1. Go to this page and download the library: Download mrclay/elgg-url-sniffer library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
mrclay / elgg-url-sniffer example snippets
$site_url = new \UFCOE\Elgg\SiteUrl('http://example.org/my-elgg-site/');
$path = $site_url->getSitePath($given_url);
if (!$path) {
// URL is not within Elgg site
// e.g. 'https://example.org/my-elgg-site/' (scheme mismatch)
// e.g. 'http://example.com/my-elgg-site/' (host mismatch)
// e.g. 'http://example.org/other-path' (not in site path)
return;
}
// let's say URL was http://example.org/my-elgg-site/blog/view/1234/my-friendly-title
// URL segments within the site. ["blog", "view", "1234", "my-friendly-title"]
$path->getUrlSegments();
// path within the site. Here "blog/view/1234/my-friendly-title"
$path->getPath();
// URL corresponds to a GUID. Here 1234
$path->getGuid();
// URL corresponds to a container GUID. Here 0 (unknown)
$path->getContainerGuid();
// an action name. e.g. "profile/edit", Here null
$path->getAction();
// a username if a profile page or null
$path->getUsername();
// test whether the path is within a given one
$path->isWithinPath("blog"); // is any blog view page, so true
$path->isWithinPath("blo"); // first URL segment must be "blo", so false
$path->isWithinPath("blog/view"); // is any blog view page, so true
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.