getPotentialUrl()

Pixelsilk API function to return what a section's url would be with different settings on URL tab in admin--requires the edit-page-properties permission
Parameters:
Urls have the following modes: PathSlash, PathName, PathNameExtension, PathSlashFile, and Rewrite.

sectionId: the unique identifier of the section (page)
urlMode: the url mode (see above)
pathName: the name of the section (based on the urlMode) without the rest of the path
extension: the extension, if there is to be one
rewriteUrl: the url to rewrite to, if that is the mode
toLowerCase: true = url in lower case; false = url not in lower case
useParentSettings: true = use parent settings; false = don't use parent settings

Output:
The function getPotentialUrl returns the url in string format

C# Example:
Guid sectionId = <section's id>;
string urlMode = "selectedMode";
string pathName = "nameOfSection";
string extension = "extensionStr";
string rewriteUrl = "urlToRewriteTo";
bool toLowerCase = false;
bool useParentSettings = true;
string potentialUrl = GetPotentialUrl(sectionId, urlMode, pathName, extension, rewriteUrl, toLowerCase, useParentSettings);
Note the capital first letter of the C# method.

HTTP Example:
Request Headers:
POST /api2/getPotentialUrl HTTP/1.1
HOST: www.example.com
Content-Length: 389
Content-Type: application/x-www-form-urlencoded
Cookie: auth=0605CC2EF64A...7761940EEC1D

Request Data:
Unencoded Data:
json={
   "sectionId":"03754619-b71b-47e7-866d-4f7856c081a0",
   "urlMode":"PathNameExtension",
   "pathName":"exampletest1",
   "extension":".html",
   "rewriteUrl":"",
   "toLowerCase":"false",
   "useParentSettings":"false"
}&token=7AdbNHZQBtwc...RPTEK8UvSUQ=

Url-encoded Data:
json=%7b%0d%0a+++...%22%0d%0a%7d&token=7AdbNHZQBtwc...TEK8UvSUQ%3d

Response Headers:
HTTP/1.1 200 OK
Set-Cookie: auth=4C7672E1A0C6...8635D38D0B2; path=/
Content-Type: text/javascript; charset=UTF-8
Content-Length: 49

Response Data:
"http://www.example.com/test/exampletest1.html"

JavaScript Example:
Method Call:
pixelsilk2.getPotentialUrl(input, callback);

Input Object:
{
    sectionId:"be799b8b-e177-47fc-97dc-d10a1d2202a1",
    urlMode:"PathNameExtension",
    pathName:"exampletest1",
    extension:".html",
    rewriteUrl:"",
    toLowerCase:"false",
    useParentSettings:"false"
}

Returned Data:
"http://www.example.com/exampletest1.html"

Back to Pages »