Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

cffeed: Atom problem

New Here ,
Mar 19, 2010 Mar 19, 2010

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?

959
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 21, 2010 Mar 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>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 22, 2010 Mar 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.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 22, 2010 Mar 22, 2010

Then posts.post_body is probably an array!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 24, 2010 Mar 24, 2010

posts.post_body is definitely a string, plus, even if I try the following:

s.entry.content = "My String";

I still get:

content should be a Array.

On the line in which the feed should be created.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 24, 2010 Mar 24, 2010

Problem clear. What if we go back, and give it what it wants, like  this

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 26, 2010 Mar 26, 2010

Thanks!  It's working now!

When I tried the code you gave me, I got the following error:

The  element at position 1 cannot be found.

However, this was easily fixed by doing the following:

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

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 26, 2010 Mar 26, 2010

Finally. Good for you! Mark that you've answered the question, for fellow developers searching for an answer to the same problem.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Mar 29, 2010 Mar 29, 2010

Hmm, you can't make your own post the correct answer?

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Mar 29, 2010 Mar 29, 2010
LATEST

That's true. I meant you should mark it as answered, which you've done.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources