Content Reference Collection Methods
In this section, we discuss the Content Reference collection methods. The methods are discussed in alphabetical order.
Syntax
DeleteItem(ContentReferenceName)
Description
The DeleteItem method deletes the content reference object identified by ContentReferenceName from the content reference Collection.
If you delete a template for a content reference, and none of the other content references on a page have a template, the default template specified with the ContentProvider is used. If there's no template for the ContentProvider, the template for the PortalRegistry is used. However, if you delete the template for the content reference, the ContentProvider, and the PortalRegistry, you receive a runtime error.
Note: The portal registry classes execute some methods "interactively", that is, as they happen. The item won't be marked for deletion, then actually deleted later. The item is deleted from the database as soon as the method is executed.
Parameters
Field or Control |
Definition |
---|---|
ContentReferenceName |
Specify the name of a content reference existing in the content reference collection. |
Returns
A Boolean value: True if the content reference was deleted, False otherwise.
Example
If Not &MyCRef.DeleteItem("Test_CRef") Then
/* can't delete test data. Do error processing */
End-if;
Syntax
First()
Description
The First method returns the first content reference object in the content reference collection.
Parameters
None.
Returns
A content reference object.
Example
&MyCRef = &MyCollection.First();
Syntax
InsertItem(ContentReferenceName, ContentReferenceLabel, Node, URL)
Description
The InsertItem method inserts the content reference object identified by ContentReferenceName into the content reference Collection.
Note: The portal registry classes execute some methods "interactively", that is, as they happen. The item won't be marked for insertion, then actually inserted later. The item is inserted into the database as soon as the method is executed.
Parameters
Field or Control |
Definition |
---|---|
ContentReferenceName |
Specify the name of a new content reference. This parameter takes a string value. If you specify a name that already exists in the collection, you get an error. |
ContentReferenceLabel |
Specify a description of the new content reference. This is the translated value. This parameter takes a string value. |
Node |
Specify a node. This parameter takes a string value. If you specify a fully qualified value for URL, you can specify a NULL (that is, two quotation marks with no space between them ("")). |
URL |
Specify a URL that contains the content. The format of this parameter depends on other properties, such as the type of content reference, where the data is stored, and so on. |
Returns
A reference to the new content reference object if the method executed successfully, NULL otherwise.
Example
The following example inserts an external content reference that is a template:
&URL = "t/" | &ITEMNAME;
&MyCRef = &CRefColl.InsertItem(&ITEMNAME, &ITEMLABEL, "", &URL);
The following example inserts a content reference where URLType is iScript (USCR):
&URL = "s/WEBLIB_PORTAL.FieldFormula.Portal_Trans_Dyn"
&MyCRef = &CRefColl.InsertItem(&ITEMNAME, &ITEMLABEL, "HRMS", &URL);
Syntax
ItemByName(Name)
Description
The ItemByName method returns the content reference object with the name Name.
Parameters
Field or Control |
Definition |
---|---|
Name |
Specify the name of an existing content reference within the content reference collection. If you specify an invalid name, the object is NULL. |
Returns
A content reference object if successful, NULL otherwise.
Example
&MyCRef = &CRefColl.ItemByName("PORTAL_ADMIN);
Syntax
Next()
Description
The Next method returns the next content reference object in the content reference collection. You can use this method only after you have used the First method: otherwise the system doesn’t know where to start.
Parameters
None.
Returns
content reference object.
Example
&MyCRef = &MyCollection.Next();