Generates an absolute URL to a registered site.
Class Name |
|
---|---|
Component |
|
Input Parameters
siteId
Identifies the site used to generate the URL. If set to null, the generated URL uses the URL of the current site.
path
Path string to include in the generated URL.
queryParams
Query parameters to include in the generated URL.
protocol
The protocol to use—http
or https
—in the generated link. If omitted, the protocol is set from the SiteURLManager
property defaultProtocol
.
inInclude
A Boolean flag, specifies whether relative paths should use the URL of the included page.
Output Parameters
output
Rendered if the URL is generated.
url
Set to the generated URL.
error
Rendered if an error occurs.
errorMessage
Contains the error message if an error occurs.
Usage Notes
Given a site ID and optional path, SiteLinkDroplet generates an absolute URL to another site. SiteLinkDroplet constructs URLs for a requested site according to the following rules:
No path supplied: New URL retains old path relative to the new site’s root.
Path contains leading forward slash (
/
): Path is relative to the new site’s root.Path omits leading forward slash (
/
): Path is relative to the current page, on the new site.
URL construction varies depending on whether production site URLs follow a domain-based or path-based strategy. The following examples show how SiteLinkDroplet generates URLs according to these diferent strategies.
Production-site URLs use path-based strategy
Target site’s production site URL:/foo
Current URL:http://domain.com/bar/dir/index.jsp
Input path | New URL |
---|---|
|
|
|
|
|
|
|
|
Production-site URLs use domain-based strategy
Target site’s production site URL:foo.com
Current URL:http://domain.com/dir/index.jsp
Input path | New URL |
---|---|
|
|
|
|
|
|
|
|
Preview query parameters
If a site link is generated on a preview server—that is, a server that is assembled with the –preview
switch—SiteLinkDroplet automatically appends two sticky site query parameters to the generated link: pushSite
and stickySite
. For more information about sticky site parameters, see the Multisite Request Processing chapter in the Platform Programming Guide.
Note: If a site ID contains unconventional characters—for example, @
(at) and ~
(tilde)—you can enter them directly for the input parameter siteId
. However, settings for input parameters path
and queryParams
must use URL encoding for non-alphanumeric characters—for example, %40
and %7E
for at (@
) and tilde (~
) characters, respectively.
Using without the dsp:a tag
The SiteLinkDroplet
servlet bean is typically used in conjunction with the dsp:a
tag to create a site link. The servlet bean calculates the URL and then the dsp:a
tag renders a link for that URL on the page. In order to tell the dsp:a
tag that it should not remap the URL to add a virtual context root, the SiteLinkDroplet
adds a query parameter, atg.multisite.remap=false
, to the request URL. The dsp:a
tag then strips this query parameter from the URL so that it does not appear on the actual link that is added to the page.
If you use the SiteLinkDroplet
on its own, the atg.multisite.remap=false
query parameter is not removed from the URL; therefore, if you use the SiteLinkDroplet
in this way, you may need to strip that query parameter from the URL.
you must strip an internally-used query parameter from the resulting URL.
Example
See SiteIdForItem.