Skip to main content
Participant
March 19, 2010
Question

cffeed: Atom problem

  • March 19, 2010
  • 1 reply
  • 1055 views

I'm trying to create an Atom feed using cffeed (funny that all of the examples on the internet use RSS).  If I leave out "content", the feed is created fine, but of course with no content.  I have the following cfscript:

s.entry.content = StructNew();

s.entry.content.value = posts.post_body;

(s is the struct I'm passing to cffeed, entry is the array that contains all of my entries using index i)

But I get the following error:

content should be a Array.

So I go ahead and change it to this:

s.entry.content = ArrayNew(1);
s.entry.content[1] = posts.post_body;

And now I get this error:

content should be a Struct.

So which is it, ColdFusion?  An array or a struct?

    This topic has been closed for replies.

    1 reply

    BKBK
    Community Expert
    Community Expert
    March 21, 2010

    It was perhaps your intention to do something like this:

    <!--- s is a struct, entry an array --->
    <cfset s.entry = arrayNew(1)>

    <!--- initialize each element in the entry array as a struct --->
    <cfloop index="i">
        <cfset s.entry=structNew()>
    </cfloop>

    <!--- content, title are keys in a struct --->
    <cfset s.entry[1].content="content_1">
    <cfset s.entry[2].content="content_2">
    <cfset s.entry[3].content="content_3">

    etc., etc.

    <cfset s.entry[1].title="title_1">
    <cfset s.entry[2].title="title_2">
    <cfset s.entry[3].title="title_3">
    etc., etc.

    <!--- more generally, in a loop --->
    <cfloop index="k"
        <cfset s.entry.content=posts.post_body>

        <cfset s.entry.title=posts.post_title>

        etc., etc.
    </cfloop>

    Participant
    March 22, 2010

    Thanks, but just setting content equal to a string was the first thing I tried.  I had:

    for (i = 1; i <= posts.RecordCount; i++)

    {

         ...

         s.entry.content = posts.post_body;

         ...

    }

    And I get the error:

    content should be a Array.

    BKBK
    Community Expert
    Community Expert
    March 23, 2010

    Then posts.post_body is probably an array!