Creating a Feed Asset

Once an RSS feed is added to OU Campus, feed items can be added to it. The feed can be assigned to a directory using access settings. When a page is created, the RSS items can be attached to a page at the time of page creation with the use of a specific template, or items can be added to a page later. Items can be edited and updated, or new items can be added. The content of these fields can be pulled in and used to populate an editable region on a page. This allows the RSS content to exist as the raw feed and be repurposed as content on a page. Fresh content can be easily published in both page forms, as an RSS XML feed, and used as a teaser or a widget-like feature on the home page or a landing page. CSS can be used to provide styling that aligns with the page or section design. What’s New Live (WNL) can be utilized to parse RSS feed item information, such as the title and description, and display it dynamically on a page using HTML styling.

A server-side script called What’s New Live (WNL) can be written in any server-side language. It includes classes, variables, and functions that parse existing feeds, and it incorporates HTML styling to layout the content. This script and the use of the Extra XML node in the feed item can be used to help create a dynamic experience for site visitors. For example:

  • Identify items for a home page and put those feed items to a specific region of a specific page
  • Display items based on category affiliation, such as for different sports teams
  • Display feeds using assets, so it can be dropped on different pages
  • Create a visitor sort so they can find relevant news items
  • Display items based on a page's keywords
  • Include a testimonial or random feed items displays

A few examples of extending functionality with the Extra XML node include:

  • Identifying items to be displayed on the home page
  • Display different feed items depending on a page
  • Can pass in the TCF and then edit in the item as necessary

Dynamic Metadata-Driven Content Areas — In combination with metadata taxonomy for content, pages can be created in OU Campus with content that is dynamically pulled into the page when the paged is served to a user’s browser. Users can select which metadata tags are desired and used to collect current content to that page.

This section includes two examples of a WNL script written in PHP as an example that is not hard-coded into the XSL, but rather can be dropped into an asset and used with existing RSS feeds.


  1. An RSS feed should already be configured for the site.
  2. A WNL script must already be included in the site configuration or otherwise added.
  3. Assets must be enabled.

Activity: The purpose of the exercise is to create an asset that includes the path to the What’s New Live (WNL) script and to an RSS feed. Provided is a generic WNL script, as well as two code snippets either of which can be used to call the script and pass to it RSS feed item values.

After the asset has been created, it can be dropped onto a page as to demonstrate the basic functionality. Once completed the published page looks similar to the one below:

RSS Feed

Adding the Script

In order to use a WNL script in the asset, the script has to have been configured and uploaded to the resources folder. This example will be using PHP, but remember that WNL scripts can be in any server-side language.

  1. Navigate to /_resources/php/ or the directory where the scripts are located.
  2. Upload the wnl-simple.php file (or create the file with any other acceptable alternative, such as copying and renaming an existing script).
  3. Save and publish.

Here is a sample PHP script that can get placed in the PHP directory:

//ini_set('display_errors', '1');
$input = $_SERVER['QUERY_STRING'];
if (!isset($items)) // # items IS NOT PASSED AS PARAMETER
      $items = 5;
     if (!isset($feed)) // FEED IS NOT PASSED AS PARAMETER
      $feed = $_SERVER["DOCUMENT_ROOT"] . "/rss/gallenauniversity.xml";
      $feed = $_SERVER["DOCUMENT_ROOT"] . $feed;

$namespace = "";
$output = "\n";
$count = 0;
if ($rss = simplexml_load_file($feed)){ // (replace relative path with variable: $rssPath ).
      foreach($rss->channel->item as $item){
            if ($count < $items) {
                  /*Set variables from RSS*/
                  $title = $item->title;
                  $desc = $item->description;
                  $link = $item->link;
                  $date = date("F d, Y", strtotime($item->pubDate));
                  // $image = $item->children($namespace)->attributes()->url;               
/*Display output*/
$output = $output . "\n".
                 "     <h5><a href=\"".$link."\">$title</a></h5>\n".
                 "     <p><strong>".$date."</strong> - ".$desc."</p>\n".                                "";
if ($count == 0)
      $output = $output . "<p>No current items found.</p>";
$output = $output . "";
echo $output;

The script defines the input variable using the server variable, query string, which passes the path of the accessed page. The parse string function is fed the input variable, which was just defined with that page path from the query string. The logic that follows determines two things: 1) if the items variable was passed in and 2) if the feed variable was passed. If the value for the items variable was not passed, then items is set to 5. This value can be changed as necessary in the script to display more items on the page. If the value for the feed variable is not passed, then the feed path is constructed by appending the path and file specified here to the document root (directory under which the current script is executing, as defined in the server's configuration file). The namespace uses the Yahoo! Media RSS Specification. The output variable writes the opening tag for an unordered list and the count initiates to 0.

The next bit of the script runs a for each loop as long as there are fewer items than count. For each item a list item is written with an H5 tag, an href with a hyperlinked title, strong formatting for the date, and the description. The list item end tag is added and the count incremented.

If no list items are found, then a message is displayed.

The actual HTML output is rather simple:

<p><strong>DATE</strong> - DESCRIPTION</p>

As a simple test, navigate to the published file. If the settings are correct, the PHP script displays the feed items with the included feed item values as follows:

Feed Items

Configuring the Asset

After adding and publishing the WNL script, the asset can be configured.

Assets are reusable content such as text, images, media, code blocks, links, etc. Reusable content is convenient when working with multiple files that require the same information. As reusable content, assets allow users to easily change an item that is used on several pages. Assets can be inserted into pages using the WYSIWYG Editor and Source Editor. Once an asset is updated and published, all the pages using the asset will also be updated and published.

By default, Level 4 users and greater can create assets. Access asset settings can be utilized to restrict access to a specific group. Assets are created from a specific site, but by default available to all sites within an account with the exception of Managed Forms and Image Galleries. In the site settings, administrators can restrict the use of Assets to the current site only for the specified group. For the Restrict users to locally-created assets only drop-down, select the group that will be able to access only locally created assets. Alternatively, when creating or by editing an Asset it can be made available only to the site in which it was created. This is accomplished with the use of the Lock to Site checkbox. Both LDP Image Galleries and Managed Forms are automatically locked to the originating site and only available to that site. The Asset Manager must be enabled at the Account level for assets to work.

Creating a Code Asset

  1. Navigate to Content > Assets.
  2. Click New.
  3. Click Source Code. This displays the screen for creating a Source Code Asset.
    Source Code Asset
  4. Define the Asset Name. A descriptive, friendly name should be used that helps users select the appropriate asset to use.
  5. Provide a Description. A brief description regarding the asset's intended purposes, usage, or content can further help organize and manage assets.
  6. Select the Lock to site checkbox to limit the asset availability to the current site. This means that if utilizing assets in another site within the same account, then the asset is not visible in the Assets section, nor available for selection in the WYSIWYG Editor or Source Code Editor.
  7. Add Tags to categorize the asset. These are used to help manage assets by being able to filter or search by a tag, or a combination of tags.
  8. Enter the Asset content. For this asset, this is edited using Source Editor and can include client-side and server-side scripts.
  9. Define the group who has access to edit this asset using Content editable by. Use the Readers group when configuring asset access settings to restrict the ability to insert an asset on a page. This is configurable by a Level 10 administrator.
  10. Click Save and Publish.

Like pages, created and saved assets can be immediately published, scheduled to publish, or sent to user for approval. An unpublished asset can even be inserted into pages; however, an asset does notrender on the production server until it has been published.

Code Content

There are two options for the code for the asset. If the page is getting parsed for PHP, the asset will include a PHP script that identifies the variables that will be passed to the WNL script.

The other is used when the page on which the asset is being placed will not be parsing for PHP. This includes a virtual include of the WNL script, and it identifies the feed path and number of items to be displayed as part of the include string.

Note: If the pages are not getting parsed by PHP, make sure to use the server-side include that has “query string” parameters. For example:

<h4>Latest News</h4>
<!--#include virtual="/_resources/php/wnl-simple.php?feed=/_resources/rss/news.xml&amp;items=5" -->

This example includes variables in the path. In some cases it may require an actual ampersand symbol “&” rather than the character encoding used in the example.

Parsed for PHP Code

For a page that gets parsed for PHP:

<h4>Latest News</h4>
$feed = "/rss/gallenauniversity.xml";
$items = 5;
@include($_SERVER["DOCUMENT_ROOT"] . "/_resources/php/wnl-simple.php");

Not Parsed for PHP Code

For a page that does not get parsed for PHP:

<h4>Latest News</h4>
<!--#include virtual="/_resources/php/wnl-simple.php?feed=/_resources/rss/news.xml&amp;items=5" -->

Displaying a Simulated Feed on Preview

Generally server-side code is not displayed on the staging server. As such, in preview, it is likely that nothing will display where the feed is expected to be displayed. It is possible to simulate a feed quite simply within the asset.

  1. Place the asset that was just created on a page.
  2. Save and publish the page.
  3. View the source code of the published page.
  4. Copy the HTML for where the feed is being displayed.
  5. Place the HTML into a text file and upload it to OU Campus.
  6. Publish this HTML page.
  7. Navigate to the asset, and add an OmniUpdate div tag to the code above the PHP code or virtual include with a path pointing to the HTML page. Be sure to hide the button.

    <h4>Latest News</h4>
    <!-- ouc:div label="wnl" group="None" button="hide" path="/_resources/php/" --><!-- /ouc:div -->
    $feed = "/rss/gallenauniversity.xml";
    $items = 5;
    @include($_SERVER["DOCUMENT_ROOT"] . "/_resources/php/wnl-simple.php");
  8. Save and publish the asset.

Now when the page is previewed, sample content will appear in the defined location.

Adding the Asset Chooser to the TCF

To make it easier to select an asset to include on a page when utilizing the New Page Wizard, the asset chooser can be added to a TCF. This is accomplished by including a variable with the Type attribute set to a value of asset. For example:

<variable name="dept_address" prompt="Department Address:" alt="The address of the department." type="asset"></variable>

Choosing the Asset

Once configured, the user can choose the asset with page creation.

  1. Click New and select the correct template. This displays the page properties including the asset chooser.
    Choosing an Asset in TCF
  2. Select Choose an Asset. By default, the Asset Chooser lists all available assets.
    Asset Chooser
  3. Assets can be filtered by tags. Filtering by tags includes the ability to view only assets of a certain asset type, from a specific site, or by tag.
    Asset Tags
  4. For example, choosing to filter by the Managed Form Asset, only displays the assets of that type. Typing in the field allows users to filter by keyword. More than one filter criteria can be selected.
    Selecting an Asset Tag
  5. Select the appropriate asset and click Select.
  6. The name of the selected asset is shown for the field.
    Naming an Asset
  7. When the page is created, the asset is inserted onto the page.

    Example of an Asset Chooser


Was this page helpful?

Additional Comments:

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