# Creating Content Selectors

A content selector targets users with personalized Web content taken from BEA's Virtual Content Repository. Content selectors return and display multiple content nodes.

When a user views a portal desktop or a portlet containing a content selector, the content selector's rules and back-end logic look for a match of properties such as the the user's profile information. If the properties match the content selector rules, the content selector runs a query and retrieves and displays all content matching the query.

Note: When library services (versioning, lifecycle status, and so on) are enabled for a BEA repository, system properties are always available (published) to queries unless the content item has a retired status. If you want to retrieve content based on its lifecycle status, you must use a the cm_objectClass system property in your content query. If your queries use only system properties only, the query retrieves all content items with matching system properties that are not retired.

Content Selectors are scoped to the enterprise application, so you can include Content Selectors in any JSPs within the enterprise application.

To create a Content Selector

1. If your server is not running, start it. With your portal application open in WebLogic Workshop, choose Tools --> WebLogic Server --> Start WebLogic Server.
2. In the Application window, right-click the data\contentselectors\GlobalContentSelectors folder and choose New-->Content Selector.
3. In the New File window, enter a name for the Content Selector in the File name field. Make sure you keep the file extension.
4. Click Create. The Content Selector designer appears.
5. In the Property designer window, you can change the display Name for the Content Selector.
6. In the Available Conditions section of the designer window, select the types of conditions under which the Content Selector will run.
   As you select conditions, corresponding links appear in the top of the designer window.

7. Click the corresponding links to create the conditions you selected, and enter the appropriate information.
8. In the designer window, click the query's empty content search link to define the query. This requires a connection to BEA's Virtual Content Repository, which is set up in the WebLogic Administration Portal.
9. You can define the query in advanced mode using WebLogic Portal's expression syntax (on the Advanced tab) or in graphical mode (on the Query tab).
   Advanced mode - In the Content Search window, click the Advanced tab and build a query using the instructions in Building Content Queries with Expressions.
   Graphical mode - Use the following steps to build a content query by selecting content properties, comparators, and values to retrieve content items.
   1. In the Content Search window, click the Query tab.
   2. Select a content type, select a Property within the content type, and click Add.
      Note: The properties you select are content properties (types) rather than property set properties such as user profile or session properties.
   3. In the Content Search Values window that appears, use one of the following tabs:
      - Values - To define the query based on a comparison to a value you enter. For example, the query could be set to retrieve content with an "investorRiskLevel" property that is marked as "high."
      - Properties - To define the content query based on the property value that is dynamically fed in from another type of property, such as a user profile property. For example, instead of creating a query based on static content properties, you can create a query that reads in the value of the current user's "investorRiskLevel" to populate the query. The query would be different for each user.
   4. Click Add. The query descriptor is added in the Content Search window.
   5. You can add more value phrases to the query, then set the appropriate option in the For multiple descriptors area at the bottom of the window.
10. Click OK in the Content Search window.
11. You can preview the content that will be retrieved by the query in the Content Preview window below the designer. If you defined the query to use values from a user profile property, the retrieved content will be different for each user, so you must enter the username of an existing user in the Preview User field, such as weblogic, to see which content will be retrieved for that user.
12. Save the content selector file.
13. To use the Content Selector, add the <pz:contentSelector> tag in the relevant JSPs. The examples in the <pz:contentSelector> topic show how to display text content (including text binaries such as HTML files) and non-text binaries (such as graphics).

To modify a Content Selector

To modify a Content Selector, open its file by double-clicking it in the Application window. Modify the appropriate conditions. Click the query link and modify the queries.

To delete a Content Selector query

1. Open the content selector file.
2. Click the query link in the Content Selector designer.
3. Select the query in the Content Search window.
4. Click Remove.
5. Click OK.

To delete a Content Selector

To delete a Content Selector, select it in the Application window, press the Delete key, and click OK in the confirmation dialog box. Also delete any <pz:contentSelector> tags in your JSPs that reference the Content Selector you deleted.

Related Topics

Tutorial: Showing Personalized Content in a Portlet

How Do I: Create a Personalized Portlet?

Content Selector Designer window

<pz:contentSelector> Tag

Personalization Conditions Reference

Creating Campaigns

Developing Personalized Applications