FindCRefForURL method: PortalRegistry class

Syntax

FindCRefForURL(URL)

Description

The FindCRefForURL method returns the content reference object corresponding to URL. The URL specified by URL must be an absolute URL.

If the exact content reference is not found, this method tries to look for the content reference again, after stripping off the query portion of the URL.

If you don't want the system searched without the query string, use the FindCRefByURL method.

Note:

The portal registry API needs the current URI of the local node to work. During runtime, it gets this information from the current Web server. For Application Engine programs, there isn't a current Web server, so it has to get this information from the database.

If you have multiple content providers with the same URI, FindCRefForURL looks for the specified content reference with all those content providers.

To access pagelet categories and their associated pagelets, use the PageletCategories collection from the PortalRegistry object, not FindCRefForURL.

Parameters

Parameter Description

URL

A URL that represents the content. This parameter takes a string value. This URL must be an absolute URL. This parameter is case-insensitive.

Returns

What this method returns depends on the condition of the content reference:

  • If the end-user has access to the URL, a content reference object is returned.

  • If the content reference is registered, but the end-user doesn't have access to it, a content reference is returned, but the only property you can access is the Authorized property.

  • If a URL isn't registered or is invalid, this method returns NULL.

Example

The following example finds a content reference from a URL. If the content reference isn't found from the full URL, the query string is stripped and the system searches again:

&UserCRef = &Portal.FindCRefForURL("http://www.example.com/crefs/psportal⇒
/technologies/?url=http%3a%2f%2faugust2004%2fipass.html");

Considerations on Returned Content References

This method returns content reference objects that aren't yet valid as well as ones that are no longer valid. When you create your program, check for these properties (ValidTo and ValidFrom) if you don't want to use them.

This method returns content reference objects that the end-user isn't authorized to. When you create your program, always check the Authorized property. This is the only property you can view from an object that the end-user isn't authorized to view.