Skip to content

$p.apiGetClosestSiteId

Overview

This is a script function that retrieves the site ID closest to the relevant site by "Site Name Search" using an Ajax POST request.

Prerequisites

  1. This function searches for the "Site name" of the site. Please set the site name in advance. Please note that this is not the "Title" of the site.
    Where the "Site name" of a site is set

Syntax

JavaScript
$p.apiGetClosestSiteId({
    id: <site ID to start search>,
    data: {
        <acquisition conditions>
    },
    done: <any process>,
    fail: <any process>,
    always: <any process>
});

Description of Each Parameter

Parameter name Description Required
id Site ID to start search. Usually, you use $p.siteId() to specify the ID of the site that is calling this method. Yes
data Acquisition conditions Yes
done API communication successful Yes
fail API communication failure -
always Completion -

Acquisition Conditions

Keyword Description Required
FindSiteNames Specify the site names you want to search for as an array. Yes

Usage Examples

Call

JavaScript
$p.apiGetClosestSiteId({
    id: $p.siteId(),
    data: {
        FindSiteNames:['ParentSite','HideSize']
    },
    done: function (data) {
        console.log(data);
    }
});

Response

JavaScript
{
    "SiteId": 12345,
    "Data": [
        {
            "SiteName": "ParentSite",
            "SiteId": 12344
        },
        {
            "SiteName": "HideSite",
            "SiteId": -1
        }
    ]
}