+

Search Tips   |   Advanced Search

Portal Scripting Interface and content associations

With the Portal Scripting Interface, we can create scripts to automate the management of content associations. Using the ContentMapping bean with the Portal Scripting Interface, we can add, modify, and remove content associations.

Before a script can work with the ContentMapping bean, establish a user session with the portal using the login command of the Portal bean. The user identity must have sufficient permissions to administer the web content pages and web content library folders referenced by the script.


Retrieve content associations

To retrieve content association information, use the select method to specify the object ID of the web content page. We can often derive the object ID for a resource from another bean and use that as input for the select method. For example, we might have a web content page with the unique name my.test.page. Using the find method of the Content bean, we can determine the object ID of the my.test.page page.

After you have the object ID of the web content page, we can use the list method and the get methods to access the content associations. The list method returns a list of content association IDs. The IDs can identify either the resource ID of a folder or the content path of the folder, depending on how the page is mapped. We can use the content association IDs returned by the list method as arguments for the get method.

The get method can return the default association for the selected web content page. The list method can retrieve a list of scopes defined for the associations of the web content page.


Add content associations

Use the add method to add new content associations to a web content page. We can assign a content association by specifying the content path of the folder or the ID of folder. If you identify the folder by content path, the association is internally transformed to actually point to the ID of the folder. As a result, if you rename the folder later, the association still points to the same folder.


Remove content associations

The ContentMapping bean provides two methods we can use to remove content associations from a web content page:

The following examples demonstrate how to remove the content associations for two web content pages. The content associations of the first page are removed individually with the remove method, and the content associations of the second page are removed with the delete method.


Modify content associations

To modify content associations, use the set method of the ContentMapping bean. We can change the following attributes:

When calling the set method, pass in the ID of the content association to update.

The following example updates two content associations for the web content page identified by the unique name my.test.page. Several settings are specified for the first content association:

For the second content association, the association scope is removed by specifying an empty string.


Parent: Content associations reference