BASICS

ADMINISTRATION

DEVELOPMENT

SUPER ADMIN

  LAST UPDATED
7/2/2013

Creating an RSS Feed Template

This section explains how to create the template for a new page wizard (TCF) that automatically generates an RSS item at page creation time. While the site being used for the tutorial already has one, which was used when discussing Directory Variables, it is still valuable to understand the attributes that can be passed, and the options available.

There are several reasons why passing the variables via the TCF is helpful:

  • It reduces replication of work effort and minimizes errors
  • It limits the user’s need to touch the items
  • It lowers the user’s need to understand RSS
  • It can give additional control to the user as they can choose the feeds to which pages are associated

The page and RSS item can use the same variable information to whatever level is desired. For instance, the title can be used on both the page and as a part of the RSS item. So the user only has to enter it once.

Additionally, users do not have to understand the RSS item fields as they will pre-populate, and the user has only to edit the page in the traditional manner. While the RSS Items icon will show on the Page Actions as soon as an RSS feed is assigned to the page, the user can ignore it unless changes need to be made.

This portion of the tutorial will review:

  • Passing the title and short description to the RSS item on page creation
  • Passing media selections to the RSS item
  • Allowing users to select the feed to which the page should be assigned during page creation
  • How to pass categories on page creation, which can then be used by a parsing script to display dynamic information on the page

Basic RSS Variables

  • Title: Generally matches page title.
  • Description: Can be the meta data and is usually short. It can be referred to as an article teaser.
  • Author: Who published the page or wrote the news article.
  • Link: A link back to the page from the item. This is included automatically and does not have to get passed.
  • Publication Date: Entered by the system upon publish.

Setting Up the Template

To get started, make a copy of the pt-new-page.tcf found in /_resources/ou/templates. Rename this TCF pt-new-news.tcf.

Edit the newly created pt-new-news.tcf:

  1. Change the current title to a new title: <title>New News Page</title>
    This is the name that will appear at the top of the New Page Wizard.
  2. Several of the basic variables already exist in this file. 

    <variable name="title" type="text" prompt="Enter Page Title:" alt="Give your new page a title."></variable>
    <variable name="description" type="text" prompt="Description:" alt="Describe your new page."></variable>
    <variable name="author" type="text" prompt="Author:" alt="The author name for this page."></variable>
  3. Update the alt tag for the description variable to read: alt="Describe your new page. This will be used as meta data and for the RSS item."
  4. Add display="no" to the page type variable, and change the selected option to Article. Make sure that Content and One Column are set as selected="false".

    <variable name="pagetype" type="select" prompt="Page Type:" alt="What type of page would you like to create?" output="xml" display="no">
          <option value="article" selected="true">Article</option>
          <option value="content" selected="false">Content</option>
          <option value="onecolumn" selected="false">One Column</option>

    </variable>
  5. Add the following attributes to the <template> node in order to echo in the values that are entered into the variables for title, description, and author into the RSS item:

    rss-title="{title}"

    rss-description="{description}"

    rss-author="{author}"

  6. Change the TMPL being called to pt-article.tmpl.

    <template prompt-prefix="New Page" filename="{filename}" extension="pcf" display-filename="no" display-group="no" display-destination="no" display-overwrite="no" preferred-redirect="yes" publish="no" autonav="{autonavigation}" rss-title="{title}" rss-description="{description}" rss-author="{author}">pt-article.tmpl</template>
  7. Save the changes. 
  8. Upload an image with the same name as the TCF: pt-new-news.gif.

Test the Template

In order to test the new template, start by:

  1. Navigating to Setup > Template Groups.
  2. Edit the News and Section template group.
  3. Check the box under the new template and save the changes.

After adding the template to the template group:

  1. Navigate back to Content > Pages.
  2. Click on the breadcrumb to get to the root of the site.
  3. Click on the access settings next to the news directory, and ensure that an RSS Feed is selected in the drop-down. If not, select one. Also check that the News and Section template group is assigned. Make any necessary changes, and Save the changes.
  4. Enter into the news directory, and click New.
  5. Select the new template.
  6. Complete the fields, and click Create.
  7. Verify that the Title, Description, and Author are populated in the RSS Items icon.
  8. Publish the page.
  9. In another tab, navigate to the live feed and observe the new item.

Passing Media Items

In addition to the standard feed item fields, media can be passed to the RSS item as well. The media will be used by feed readers that support media. The selected media can also be passed to the page content upon page creation and can be used with scripts that parse and display the feed items on a page, such as the homepage.

  1. Navigate to the pt-new-news.tcf in the /_resources/ou/templates.
  2. Add the following variables to the TCF. The variables:
    a.  Allow the user to determine whether a selected image is displayed on the page or not. 
    b.  Allow the user to select an image, which will be used both as part of the page when image teaser is set to yes and as part of the media options. 
    c.  Allow the user to select a thumbnail image, which can be used as part of the output display. 

    <variable name="image_teaser" type="select" group="Everyone" prompt="Show Article Image:" alt="Do you want to display the article with an image teaser?" output="xml">
    <option value="true" selected="true">Yes</option>
          <option value="false" selected="false">No</option>
    </variable>
    <variable name="article_image" type="filechooser" group="Everyone" prompt="Article Image:" alt="Please choose a suitable image for the article. This will be used as the RSS image too." path="/images/news/">/images/news/american_football.jpg</variable>
    <variable name="thumb" type="filechooser" path="/images/news/thumbs/" prompt="Thumbnail Image:" alt="RSS Thumbnail Image">/images/news/thumbs/american_football.jpg</variable>
  3. In the <template> node, add the following. The order is important and must always be input as described. The ^^ identifies that a new value is being passed. This passes:
    a.  Title: The title is passed as the title of the image. 
    b.  Link: The full sized image is passed as the image link. 
    c.  Description: The description is passed as the description of the media. 
    d.  Thumbnail: A thumbnail image is passed as the thumbnail. 
    e.  Keywords: This ast option would pass keywords to the media. This is being skipped at this time. 

    rss-media="{title}^^{article_image}^^{description}^^{thumb}"
  4. Save the changes. 
  5. Open the pt-article.tmpl file. 
  6. Change the path for the article image parameter back to /images/news.

    <parameter name="article_image" type="filechooser" group="Everyone" prompt="Article Image:" alt="Please choose a suitable image for the article." path="/images/news"><!--%echo var="article_image" --></parameter>
  7. Note the two parameters that are echoing in the image teaser and article image selections. 
  8. Save the changes. 

Test the changes:

  1. Click on the breadcrumb to get to the root of the site.
  2. Enter into the news directory, and click New.
  3. Select the new template.
  4. Complete the fields, taking note of the newly added ones, and click Create.
  5. Verify that the Title, Description, and Author are populated in the RSS Items icon.
  6. Click on the media, identified by the title, and verify that all media options, except Keywords, were passed.
  7. Publish the page.
  8. In another tab, navigate to the live feed and observe the new item.

Selecting a Feed

A template has been created that passes the necessary RSS item information. However, an administrator still has to set the feed to which new items are added in the access settings prior to the template being used. This feed selection can be passed by the TCF in one of three ways:

  1. With a hard-coded feed selection in the <template> node
  2. Using a filechooser, allowing user selection
  3. Using a drop-down, allowing user selection

The benefit of allowing users to select which feed they want to publish to is that it empowers users and minimizes the amount of Level 10 administrator intervention that is required. It also allows items to be added to the appropriate feeds when multiple feeds are being used.

Drop-Down or Filechooser

Either of these can be created by adding to the previously added RSS variables. This entails creating another variable with the named “feed.” Since a template already exists in the sample site that uses a drop-down variable, this example will use a filechooser. It is important to understand the pros and cons of both.

Drop-Down

A drop-down selector gives the administrator the power to choose which feeds are available to the user for selection. This helps eliminate the inclusion of feeds that may have specific purposes and should only contain items that administrators specifically designate. It also prevents users from accidentally choosing an aggregate feed, which should only have members and not its own individual feed items. Drop-down selectors also give the administrator the ability to add friendlier names for the feeds rather than the filename.

However, if additional feeds are added, the administrator will need to update the template to make them available.

Filechooser

The filechooser option allows users to choose from all currently published feeds. Administrators do not have to touch the templates when adding new feeds.

The user does have to be aware of which feeds are aggregate feeds as items should never be added to those, and selecting a feed may be more difficult due to the selection being made by the filename.

If using the filechooser option, make sure to Rebuild the feed when first creating it in order for it to be available in the filechooser.

Creating the Filechooser Variable

To add a filechooser variable for selecting a feed, navigate to /_resources/ou/templates, select the pt-new-news.tcffile, and add the following after the media variables that were added previously:

<variable name="feed" type="filechooser" path="/rss" lockout="yes" prompt="RSS Feed:" alt="Select an RSS feed for the page.">/rss/news.xml</variable>

A new attribute of lockout="yes" has been added to restrict users from selecting a file from a different folder.

Pass this new variable to the <template> node. In the template node add:

rss-feed="{feed}"

Save the changes.

Test the changes:

  1. Click on the breadcrumb to get to the root of the site.
  2. Enter into the news directory, and click New.
  3. Select the new template.
  4. Complete the fields, taking note of the newly created filechooser, and click Create.

Click on the access settings for the new file, and observe the RSS Feed selected.

Adding Category Selections

In addition to the common options already discussed, it is also possible to pass extra XML nodes. This is generally used for things like passing a homepage indicator or categories. These extra XML nodes can then be used in the script that parses and displays the feed on a page. For instance, many feed items may be added to a given feed, but only certain items may be desirable to have on the homepage. A selector can be added to the TCF allowing the user to choose whether or not the item is added to the homepage, which then gets passed to the Extra XML.

To add extra XML nodes, define the variable selectors in the TCF. Additionally, two variables that are not displayed need to be created. These create the opening and closing tags for the extra XML nodes.

As an example, if a homepage selector was desired, the following could be added to the TCF:

<variable name="rss-home" type="select" prompt="Add to homepage?" alt="Do you want to display the item on the homepage feed?">
      <option value="yes" selected="true">Yes</option>
      <option value="no" selected="false">No</option>
</variable>
<variable name="hopen" display="no"><home></variable>
<variable name="hclose" display="no"></home></variable>

This creates both the drop-down for the user’s selection, and the opening and closing tags for the extra XML node.

Drop-Down in TCF

Drop-Down in TCF

 

This will pass the variable data to the RSS item. 

Populated Extra XML Node

Extra XML Node

 

The new template is now ready to use with all desired data. 


Was this page helpful?

Additional Comments:


(Include your email address if you would like a reply)