interactivetools.com
Quickstart Guide...
How to Install
How to Upgrade
How to Move Servers
How to Private Label
Restore Hacked Sites
Admin Menu
General Settings
Private Labeling
User Accounts
Section Editor (List)
Add New Editor
Section Editor (Edit)
Field Editor
Text Field
Text Box
Wysiwyg
Date/Time
List
Checkbox
Upload
Separator
Regional Settings
Code Generator
Show Code
Viewers
Viewer Options
Displaying Uploads
Search Engines
Advanced Topics
In-Depth Getting Started Guide
Working With Generated Code Guide
Using SlideShowPro With CMS Builder
Special Fieldnames
Changing and Removing File Extensions
Demo Mode

View Changelog »
Glossary
Need Help? Questions?
Post in forum »

Creating an RSS Feed

This guide will walk you through the steps required to set up an RSS feed with CMS Builder.
To begin, we'll need to create an XML file used to display your RSS feed. Create a new plain text file and paste this code into the first line:


<?php header('Content-type: application/xml; charset=utf-8'); ?><?php echo '<?xml version="1.0" encoding="UTF-8"?>'; ?>
Now log in to CMS Builder, go to the Code Generator page, select the section you want to set up the RSS feed for, and use the List page setting to generate the code. You can adjust the other options if you'd like. Now paste the "STEP 1" code that you just genereated after the first line we added earlier. Here's an example of the "STEP 1" code block:


<?php
  /* STEP 1: LOAD RECORDS - Copy this PHP code block to the TOP of your page BEFORE anything else. */
  require_once "/path/to/cmsb/lib/viewer_functions.php";

  list($newsRecords, $newsMetaData) = getRecords(array(
    'tableName'   => 'news',
  ));

?>
After that chunk of code, add this code in, replacing the various pieces of capitalized text as required:


<rss version="2.0"> 
  <channel> 
    <title>PUT YOUR SITE NAME HERE</title> 
      <link>http://EXAMPLE.COM/YOUR/URL/HERE/</link> 
      <description>YOUR SITE DESCRIPTION GOES HERE</description> 
      <pubDate><?php echo date('r'); ?></pubDate> 
      <language>en-us</language>
Finally, add this code in below:


<?php foreach ($newsRecords as $record): ?> 
        <item> 
          <title><?php echo htmlspecialchars($record['title']) ?></title> 
          <link><?php echo $record['_link'] ?></link> 
          <description><?php echo htmlspecialchars($record['summary']); ?></description> 
          <pubDate><?php echo date("r", strtotime($record['date'])) ?></pubDate> 
          <guid isPermaLink="true"><?php echo $record['_link'] ?></guid> 
        </item> 
<?php endforeach ?> 
 
  </channel> 
</rss>
You'll want to make sure that the "$newsRecords" variable used in the first line above is changed to your section's variable name, which you should see in the "STEP 1" code you generated earlier. Also, if you're not using a full URL in your "Viewer URL" settings in the software, you'll want to either adjust that setting so that it includes "http://www.yourdomain.com/", or change these lines of code in your RSS file:


          <link><?php echo $record['_link'] ?></link> 
          <guid isPermaLink="true"><?php echo $record['_link'] ?></guid> 
So that they look like this:


          <link>http://www.yoursite.com<?php echo $record['_link'] ?></link>
          <guid isPermaLink="true">http://www.yoursite.com<?php echo $record['_link'] ?></guid> 
Now save this file as "rss.xml.php" and upload it to your web server - it should be ready to go!
Copyright © 1999-2016 interactivetools.com, inc.