Wednesday 20 August 2008 12:14:00 pm
We will create a new class to contain the imported RSS items. It is possible to load RSS data into any eZ Publish object class, but creating a new custom class provides the following benefits:
Note that you do not need to create a new RSS item class for every new RSS feed you import. You might have, for example, a class for RSS news items and another for RSS blog items.
At this point it is useful to examine the contents of the RSS feed you want to import. This can be done by saving it to your computer and then examining the file with a text editor or using “View – Page Source” in your web browser.
The following illustration has been formatted and edited slightly to make the structure clearer. It shows the basic structure of the news items in the BBC Tennis RSS feed. There is a certain amount of header information, as shown below, but the main area to pay attention to is the content of the actual news items. This is because it will directly influence how the new class should be structured.
Example RSS elements
Looking at the RSS item above, the following elements are useful to import:
First, click the Setup tab in the Administration Interface. Then, click the Classes link in the left menu. In the Class groups window, click the "Content" class group, then click the New class button.
This will bring up the Class Edit Interface, as shown below:
Class edit interface
To add each attribute, select the attribute type from the dropdown list at the bottom of the page, then click the adjacent Add attribute button. Rather than repeating each individual step to create the class in this article, the final class information is summarized below.
Name | Identifier | Attribute Type | Default Value | Flags |
---|---|---|---|---|
Title | title | Text line | Empty | Searchable |
Description | description | Text block | (not applicable) | Searchable |
Link | link | URL | (not applicable) | |
Source | rss_source | Text line | Empty | |
Publication Date & Time | pub_date_time | Text line | Empty |
Once these attributes have been entered, click the OK button to save the new class.
Now that we have created the class for the imported RSS objects, we need a location at which to place the objects.
First, click the Content structure tab in the Administration Interface. Next, navigate to the location where you want to place a container for the “RSS Item” objects and create a "Folder" object (although any other container object will do, depending on your needs).
Once the folder has been created, it is important to set the sorting order for its sub-items. This will make it possible to present, for example, an embedded view of the five most recently imported RSS items. At the bottom of the Sub items window, set the sort method to use the published dates in descending order:
Setting the sort method