23 Creating Collection Assets, Query Assets, and Page Assets

A collection asset stores an ordered list of assets of one type. A query asset stores a database query for retrieving a list of other assets from the database. Page assets are site design assets that store references to other assets in a designed fashion. Easy-to-use forms are available in the Admin interface for you to create collection, query, and page assets.

23.1 About Creating Assets

The core asset types delivered with WebCenter Sites provide the basic site design logic. Because you assign Template assets to your other assets, it is typical to create your templates before you create your site design asset types.

Coding Templates for In-Context and Presentation Editing describes how to create Template assets.

The procedures for working with assets of any type are very similar and are described thoroughly in Working with Assets in Using Oracle WebCenter Sites. This chapter presents procedures that are unique for the collection, query, and page asset types.

23.2 Creating Collection Assets

Content contributors use collection assets to store ordered lists of assets. Each collection asset can store a list of assets of one type only. You create (or design) a collection asset by naming it and selecting query assets for it. By default, you can select up to three query assets. You can create additional associations for additional queries if the need arises.

For information about creating associations, see Configuring Association Fields (Optional) in Creating Basic Asset Types.

A collection uses a query asset to obtain a list of possible assets for the collection. You build (or populate) a collection by running its queries, selecting assets from the results of the queries, and then ranking and ordering the assets that you selected. This ranked, ordered list is the collection.

Using collections is one way to keep the content displayed on rendered pages current and up-to-date. For example, you can have a site that uses several collections. If you select a collection to be displayed on an asset, a publisher or content contributor can then change the content identified by that association by doing one of the following:

  • Selecting a different collection from the tree

  • Building the assigned collection and selecting different assets in it

This section includes the following topics:

23.2.1 Before You Begin

Before you create collection assets, note the following:

  • A collection must have at least one query, so be sure that you create the queries before you try to create your collections.

  • Because you assign templates to collections, you should also create the Template assets before you create your collection assets.

Before you build the collection, you should determine how the Template asset assigned to it is coded. For example, if you select 100 assets for a collection but the template is coded to display only five of them, the following occurs:

  • The rendered page that displays those assets displays only the first five.

  • The page takes longer to render than necessary because WebCenter Sites has to sort through all 100 assets even though it displays only the first five.

For more information about building a collection, see Determining Function Privileges in Administering Oracle WebCenter Sites.

23.2.2 Creating a Collection Asset

You can create a collection asset through the Admin interface.

Note:

To use this procedure, you must have Collection asset types enabled for the site you are working in. Step 4 indicates whether they are enabled.

  1. Open the Admin interface.
  2. Ensure you have completed the steps in Before You Begin.
  3. Click New on the button bar.
  4. Select New Collection from the list of asset types. (If Collection asset types are not enabled, the option is not displayed.)

    The Collection form opens.

  5. (Required) In the Name field, type a descriptive name for the page. You can enter up to 64 alphanumeric characters, but the first character must be a letter. Underscores (_) and hyphens (-) are acceptable, but tab and space characters are not.
  6. In the Description field, type a brief description of the collection. You can enter up to 128 characters.
  7. (Required) In the Subtype field, select the type of asset this collection will hold.

    Note:

    Collection subtypes are controlled by Query. When a query is set up for a certain asset type, that asset type becomes a value of the Subtype field. The SubType field thus lists every asset type for which a query was created. See Creating a Query Asset.

  8. In the Select a Template field, select a Template asset from the drop-down list.
  9. In the Category field, select a category from the drop-down list. (If you do not select a category, the first item on the list is selected by default.)
  10. In the Keywords field, enter keywords that you and others can use as search criteria in the Advanced Search form when you search for this collection in the future.
  11. In the Associated queries section, select up to three queries. All of the queries that you select for this collection must return assets of the same type.
  12. Click Save.

23.2.3 Sharing a Collection Asset

Before you share a collection asset, consider the following:

  • Building a collection in one site builds it in all of the sites that it is shared with. You cannot build a collection to include different assets for different sites.

  • The query assets used in the shared collection must be coded to return only assets that are shared to all the sites that the collection is shared with.

  • As with any shared asset, be sure that the template assigned to the collection is also shared to the other site.

For the basic procedure on sharing assets, see Sharing Blog Assets Sharing Blog Assets in Administering Oracle WebCenter Sites.

23.3 Creating Query Assets

A query asset stores a database query that retrieves a list of other assets from the database. If you plan to use a query for a collection, remember that it returns assets of one type only.

See these topics about query assets:

23.3.1 How to Use Query Assets and Other Assets

WebCenter Sites uses queries differently in collection assets than it does for other assets:

  • When you build (or populate) a collection, you run one or more query assets and then select and order the assets that you want from the resulting list. The collection is a static list of assets selected from the query resultsets.

  • You can select queries for a page asset either through informal relationships or through named associations. You can select queries for other asset types (article, for example) through named associations.

    When the asset is rendered, it does not invoke the query directly. Either the template element that formats the asset or a template element that formats the query is coded to invoke a standard WebCenter Sites element called:

    OpenMarket/Xcelerate/AssetType/Query/ExecuteQuery
    

This element runs the query asset when the asset it is associated with is rendered, which means the resultset is dynamic.

23.3.2 How to Store the Query

A query asset can store its database query in one of two ways:

  • Directly. You can write the query directly into the SQL query field of the Query form. You can either use standard SQL for the query, or, if your WebCenter Sites systems use an external search engine, you can use an appropriate search engine query.

  • Indirectly. You can write the query in an element and then store the location of that element in the query asset by identifying it in the Element name field in the Query form. An element for a query is like any other element: you can use XML, JSP, JavaScript, HTML, and so on.

The following code is an example of a query named News Wire Feed which is stored directly; that is, the SQL query is written directly into the SQL query field in the Query form:

SELECT DISTINCT Article.id, Article.name, Article.updateddate, 
Article.subheadline, Article.abstract, Article.description, 
Category.description AS category, StatusCode.description AS 
statusdesc FROM Article, Category, AssetPublication, StatusCode 
WHERE Article.status!='VO' AND Article.category=Category.category 
AND Article.status=StatusCode.statuscode AND Category.assettype='Article' 
AND Article.source='WireFeed' AND Article.category='n' AND Article.id = 
AssetPublication.assetid AND AssetPublication.pubid = 968251170475 
ORDER BY Article.updateddate DESC

23.3.3 Commonly Used Fields for Queries

There are several WebCenter Sites fields, four of which are used in the preceding News Wire Feed query example, that you are likely to use in your queries:

The rest of this section defines the fields in this list.

status

All assets have a status. When an asset is created, WebCenter Sites adds a row to the table that holds assets of that type and sets its status to PL, which means created.

This table lists and defines the status codes that WebCenter Sites uses.

Table 23-1 Status Codes

Status Code Definition

PL

created

ED

edited

RF

received (from XMLPost, for example)

UP

upgraded from Xcelerate 2.2

VO

deleted (void)

These codes are listed in the StatusCode table in the database.

When an asset is deleted, WebCenter Sites changes its status to VO and renames the string in its Name field to its object ID.

Write your queries to exclude assets whose status is VO. For example: WHERE Article.status!='VO'

updateddate

The information in the updateddate field represents the date on which the information in the status field was changed to its current state. Depending on the design of your site, you can use a query to return assets based on this date.

category

The category is a default WebCenter Sites field that can categorize assets according to a convention that works for your sites. It is not required.

For example, if you had a banking site, you could have categories named Personal Finance, Banking and Loans, Rates and Bonds, News, and so on. You add categories for your sites on the Admin tab in the tree. See Configuring Categories (Optional) in Creating Basic Asset Types.

If you use category with your assets, you can write your queries to use category as a parameter. In the previously mentioned News Wire Feed query example, the Article.category='n' statement includes article assets from the News category.

pubid

A pubid is a unique value that identifies a site (or, in old terminology, a publication). When an asset is created, WebCenter Sites writes information about that asset to several database tables, one of which is the AssetPublication table.

An asset's row in the AssetPublication table includes the pubid of the site the asset was created for. If the asset is shared, the AssetPublication table has a row for each site that the asset is shared with. For example, if an article asset is available in two sites, there are two rows for that article in the AssetPublication table.

If you have only one WebCenter Sites site on your system or if your query results do not have to be site-specific, you do not have to code your queries to consider pubid. However, if you do not want your queries to return assets from another site, you can code your queries to restrict assets based on the pubid of the site.

startdate and enddate

Neither of the sample sites use the startdate and enddate fields but the WebCenter Sites database has columns to store this information. These fields exist so that you can assign time limits to assets. If your asset types use the startdate and enddate fields, you can create queries that select assets based on the dates stored in those fields.

23.3.4 Before You Begin Creating Query Assets

Before you begin creating query assets, consider the following:

  • Query assets that are used on assets other than collections are not required to have templates. You can either create template elements specifically for your query assets that identify, run, and display the results, or you can code the template elements for your page assets to do that.

  • When you write a query for a collection, be sure to code it to select the fields that are required for that asset type. WebCenter Sites is programmed to expect information from an asset type's required fields so that it can display that information in the Build Collection form.

  • Query assets that are used only for collections have no need for templates. The template element assigned to the collection formats the assets in a collection's list of assets.

  • For performance reasons, be sure to create efficient queries. For example:

    • Include as much logic as possible in the query rather than in the element that runs and displays the results of the query. For example, to filter or constrain a list of articles, be sure the query performs the filtering or constraining step so that the list returned to the element is complete rather than coding the query to return the entire list and using the element code to constrain the list.

    • Be sure your queries return only the information that the element displays.

  • Query assets that are for collections must return assets of one type only.

23.3.5 Creating a Query Asset

You can create a query asset through the Admin interface.

  1. Open the Admin interface.
  2. Click New on the button bar.
  3. Select New Query from the list of asset types. (Query asset types must be enabled for your site.)

    The Query form opens.

  4. (Required) In the Name field, type a descriptive name for the query asset. You can enter up to 64 alphanumeric characters, but the first character must be a letter. Underscores (_) and hyphens (-) are acceptable, but tab and space characters are not.
  5. In the Description field, type a brief description of the query. You can enter up to 128 characters.
  6. In the Template field, select a Template asset from the drop-down list.
  7. In the Category field, select a category from the drop-down list. (If you do not select a category, the first item on the list is selected by default.)
  8. In the Result of query field, select the type of asset that this query returns. (The query can return assets of one type only if this asset is to be used by a collection.)
  9. Do one of the following:
    • To store the query directly in this asset, select Database, and in the SQL query field write your query.

    • If you wrote the query in an element, select Element and then enter the entire name of the element in the Element name field.

  10. Click Save.

23.3.6 Sharing Query Assets

If you plan to share a query asset with another site, consider the following tips:

  • If you want your query results to be site-specific, be sure to include a WHERE clause for pubid so that the query does not return assets to a site where those assets have not been shared.

    • For example, in either a query for a collection or a query for a static site, you can use the following statement:

      WHERE AssetPublication.pubid = SessionVariables.pubid

      because SessionVariables.pubid is always set when you are building a collection or using the Export to Disk function.

    • If the query is to be used on a dynamic site, you can use that same statement if you code your elements to either pass in the identify of pubid to the ExecuteQuery element or to set the SessionVariables.pubid variable.

  • Because page assets cannot be shared, you should not share query assets if they return page assets.

  • As with any shared asset, if the query has a template, be sure that the template assigned to the query is also shared with the other site.

23.3.7 Previewing and Approving Query Assets

First, remember that not all query assets have their own templates. If a query asset was designed to be used on a page asset and it is the page asset's template that actually formats the query, you must preview the page to preview the query.

If your online site is a dynamic site (that is, you use the Mirror to Server publishing method) a query asset might return different assets on the management system than it does on the delivery system, depending on which assets have been published.

Therefore, if you preview your query to determine whether you should approve it or not, remember that the assets that it returns on the management system (where you are previewing it) could be different than the assets that it will return on the delivery system after it is published.

23.4 Creating Page Assets

Page assets are site design assets that you use to store references to other assets, organizing them according to the design that you and the other designers are implementing.

These page assets represent sections of the site, in essence the structure or organization of the site. They do not represent each and every rendered page that can possibly be served. This structural organization is primarily for the benefit of your WebCenter Sites users. This is not the only way of organizing your site, but it is convenient for your editors to see a structure that resembles your finished website.

Typically, you create page assets once: when you design the site. You associate collections, queries, articles, and so on with page assets and you code template elements that format the types of assets you want to associate with the page asset.

Before you can select the correct content for your page assets, you must be familiar with how your site is structured and what your template elements for page assets are designed to do. That is why you and other site developers (the people who are coding elements and creating Template assets) typically create the page assets for a site.

This section includes the following topics:

23.4.1 Understanding the Page Asset Model

The page asset model is similar to the flex asset model. This provides an option to change the data structure of the Page asset. The page asset model is made up of the following asset types:

  • Page attribute

  • Page definition

  • Page

The following are some general characteristics of the page asset model:

  • Page assets are described by the page attributes that you select for them.

  • The page attributes that characterize page assets are themselves assets. This means that attributes can be passed through workflow, edited, monitored by revision tracking, and subjected to all other content management operations.

  • If you ever have to add attributes to your asset types in the future (a common occurrence with products), you just create the new attribute and assign it to the appropriate definitions.

  • This asset model supports assets that have many, many attributes, which means that you can support large sets of data.

  • The page asset model does not have parent definition asset type and parents asset type like the typical flex family, and it does not support data inheritance.

23.4.2 How To Design Page Attributes

Topics:

23.4.3 How to Create a Page Asset

To create a page asset:

  1. Log in to WebCenter Sites, select the site you want to work with and the icon for the Oracle WebCenter Sites: Contributor interface.

  2. Find and bookmark the assets (articles, queries, images, collections, and so on) you want to include on the page. Do the following:

    1. In the Search field, enter criteria identifying the asset(s) and then click the magnifying glass icon. A search tab opens displaying the results of your search.

    2. In the search results list, select (Ctrl+click) the assets you want to bookmark.

    3. In the search tab's toolbar, click the Bookmark icon.

    4. Repeat this step until you have bookmarked all of the assets and then continue with the next step.

    A tab opens displaying the results of your search:

    WebCenter Sites displays a confirmation message and also lists the bookmarked assets under the Bookmarks node in the My Work tree.

  3. In the menu bar, select Content, then New, and then Page Asset. In this example, we use the Page (Home) asset type in the avisports sample site.

    Note:

    If you are using the avisports sample site, assets of type Page are configured to open in Web Mode. Therefore, when you select to create a Page (Home) asset, the Create Page (Home) dialog box is displayed.

    In the Create Page (Home) dialog box, do the following:

    1. In the Select Layout field, select the layout you want to assign to the page.

    2. In the Name field, enter a name for the page, and then click Continue.

    3. In the avisports sample site the page definition is chosen when you select the type of page asset you will be creating. However, if this is not the case in the site you are working with, you will see a Page Definition field. Use this field to specify the page definition for the page you are creating and then click Continue.Switch to Form Mode. In the asset's toolbar, click the Mode switch. Continue to step 4b.

    4. The asset's Create view is displayed in Form Mode.

  4. Create the Page asset.

    1. In the Name field, enter a name for the page. type a descriptive name for the page. You can enter up to 64 alphanumeric characters, but the first character must be a letter. Underscores (_) and hyphens (-) are acceptable, but tab and space characters are not.

    2. Page Definition field (if applicable): In the avisports sample site the page definition is chosen when you select the type of page asset you will be creating. However, if this is not the case in the site you are working with, you will see a Page Definition field. Use this field to specify the page definition for the page you are creating and then click Continue.

    3. In the Template field, select a template from the drop-down list.

    4. To add items, select the assets from the Bookmarks node in the My Work tree and then drag and drop the selected items into the field.

  5. In the asset's toolbar, click Save.

    The page is saved. It now displays in the Site Tree under the Unplaced Pages pages node.

23.4.4 How To Place Page Assets

After you create a page asset, you position it in the appropriate location in the site tree by using the Place function.

  1. Open the Admin interface.
  2. Click the Site Navigation tab, where you should see the site tree with the new page asset in the Unplaced Pages list.
  3. Expand the site navigation node under which you want to place the page asset.
  4. Select a parent for the page you are placing by doing one of the following:
    • To place a page at the top-most level in the tree, right-click the site navigation node and select Place Page from the context menu.

    • Otherwise, right-click the placed page under which you want to insert the new unplaced page, and choose Place Page from the context menu.

    The place page form opens in the work area on the right. It lists all child pages that are placed under the parent page. It also lists all pages that have not yet been placed in the site tree:

  5. To place the page, type a number in the Rank field in the list of unplaced pages to designate the new page's position in the list of child page assets. Position numbering starts at 1, at the top of the list.
  6. Click Save.

    The unplaced page asset moves to the site tree, to its assigned rank. To view the page asset in its new location, you may have to right-click in the site tree and choose Refresh All from the context menu.

23.4.5 How To Move Page Assets in the Site Tree

In addition to placing unplaced pages, you can also use the place page form to:

  • Change the order of child pages within the same parent page.

  • Move a child page from one parent page to another.

23.4.5.1 Reordering Child Pages

To re-order children of the same parent page:

  1. Open the Admin interface.
  2. Click the Site Navigation tab and expand the site navigation node containing the pages you want to re-order.
  3. Right-click a placed page that has multiple child pages, and choose Place Page from the context menu.

    The place page form opens in the work area on the right.

  4. In the list of placed child pages, type new values in the Rank column to re-order the child pages.
  5. Click Save.

    The child pages move to their new positions in the site tree.

23.4.5.2 Changing Parent Pages

To move a child page from one parent page to another:

  1. Open the Admin interface.

  2. In the Site tree, expand the Site Navigation node, and then expand the site navigation node containing the child page you want to move under a different parent page.

  3. Remove the page asset from its parent page:

    1. Right-click the placed page whose child page you want to move, and choose Place Page from the context menu.

      The place page form opens in the work area on the right.

    2. In the list of placed child pages, select the Remove check box next to the child page that you want to move.

    3. Click Save.

      The child page moves to the list of Unplaced Pages in the site tree.

  4. Place the page asset under its new parent page:

    1. In the site tree, right-click the placed page where you want to insert the unplaced child page, and choose Place Page from the context menu.

      The place page form opens in the work area on the right.

    2. In the list of unplaced pages, type a number in the Rank field to designate the new page's position in the list of child page assets. Position numbering starts at 1, the top of the list.

    3. Click Save.

      The previously unplaced page asset moves under the site navigation node containing the parent asset, in its assigned rank.

23.4.6 Considerations About Placing Page Assets and Workflow

WebCenter Sites has a workflow feature that controls the flow of assets as they pass from one team member to another; for example, from author to editor to approver to publisher. The workflow administrator can create processes that control who can place page assets in the site tree and during which workflow step they can do so. Note the following:

  • The Place Page workflow privilege controls all place page functions: Place Pages, Remove, and Rank.

  • You must have the proper privileges for both the parent page on which you invoke Place Pages, and for any child page that you want to Rank or Remove.

For information about the workflow process, see Creating and Managing Workflow Processes in Administering Oracle WebCenter Sites.

23.4.7 Tips About Editing Page Assets

In general, there are two ways to edit an existing page asset:

  • Change the assets, but not the asset types, that are included on the page. For example, move new assets to the Contains list from your Bookmarks; select a different collection, query, or article from a named association field; or rebuild a collection associated with the page asset to include different assets.

  • Create a new association or change the actual structure of the page asset in some way.

Although you may frequently change the content in the collections or queries on a page at regular intervals, you are less likely to change the associations, asset types, or structure of a page after the site goes live. This may also require you to edit the code in the template element that formats the page.

23.4.8 Considerations About Deleting Page Assets

During your site design phase, it is likely that you will create and delete many page assets. However, before deleting a page asset from a site that you have published, be sure that you understand the consequences. For example:

  • Have you removed references to the page from other page assets?

  • Are any of your other page templates coded to extract and use information about this page asset in any way?

Before you delete a page asset, be sure to remove any references to it from any other elements or pages. It is a good idea to unplace a page asset before you delete it.