|
|
Home /
Groups /
ColdFusion Talk (CF-Talk)
Cffeed - creating RSS Feeds and guid
I'm trying to use cffeed in ColdFusion 8 to create an RSS 2.0 feed. INathan C. Smith 09/14/07 05:49 P Don't feel too bad. The docs for CFFEED leave a _lot_ out. This blogRaymond Camden 09/14/07 06:14 P > Don't feel too bad. The docs for CFFEED leave a _lot_ out. This blogNathan C. Smith 09/14/07 06:31 P Hi Nathan C. SmithJayesh Viradiya 09/16/07 10:27 P Hi Nathan,Jayesh Viradiya 09/17/07 05:51 P Jayesh, I was able to create a NPE by not supplying isPermaLink:Raymond Camden 09/17/07 06:18 P > I believe href will then be used for the value. If not, tryNathan C. Smith 09/14/07 06:58 P I found it. If you look in the CFML 8 Reference, page 191, there is aRaymond Camden 09/16/07 05:02 P OK, According to Jayesh Viradiya (Thanks Jayesh!)Nathan C. Smith 09/17/07 05:57 P Jayesh - what about my comment about using "ID" in query? It workedRaymond Camden 09/17/07 06:12 P I've confirmed that what you say is right Jayesh - guid works when youRaymond Camden 09/17/07 06:19 P Yes Ray....What you have mentioned is correct. For Query, ID=GUID. AndJayesh Viradiya 09/17/07 07:10 P I'm trying to use cffeed in ColdFusion 8 to create an RSS 2.0 feed. I basically lifted the example from the docs. I'm running into problems with the guid field. I used Feed validator to check what I had (http://feedvalidator.org/docs/warning/MissingGuid.html) and it told me I was missing a GUID field. I added the field in my code: <cfset myStruct.item[i].guid = qryRSS.permalink> And CF told me it had to be a struct. So if I create a new struct for guid, what do I use as names to refer to the fields? I don't think it is clear in the docs. Can someone correct me? I'm not entirely comfortable with structures so if I'm being daft please point that out gently. Thanks. -Nate Don't feel too bad. The docs for CFFEED leave a _lot_ out. This blog article is a good example: http://www.coldfusionjedi.com/index.cfm/2007/8/22/Metadata-properties-for-CFFEED So as to your problem, I looked here: http://feedvalidator.org/docs/rss2.html#ltguidgtSubelementOfLtitemgt and I see one example has guid as a simple value. One has it like so: http://feedvalidator.org/docs/rss2.html#ltguidgtSubelementOfLtitemgt So this is what I'd try. <cfset myStruct.item[i].guid = structNew()> <cfset myStruct.item[i].guid.href = qrtRSS.permalink> I believe href will then be used for the value. If not, try link perhaps. ----- Excess quoted text cut - see Original Post for more ----- > Don't feel too bad. The docs for CFFEED leave a _lot_ out. This blog > article is a good example: > > http://www.coldfusionjedi.com/index.cfm/2007/8/22/Metadata-pro perties-for-CFFEED ----- Excess quoted text cut - see Original Post for more ----- Gave those a try. Cfdump shows the values are making it into the struct, but something goes wrong in cffeed. The error: "The system has attempted to use an undefined value, which usually indicates a programming error, either in your code or some system code. Null Pointers are another name for undefined values. " I assume that means that the name of the vlue they expect is empty and different from the one I have given them. I tried url, href, permalink, link, guid, value and among others. -Nate Hi Nathan C. Smith Could you please isolate the code which throws the Null Pointer exception and post it here or send it to me at "jayvir@adobe.com" for us to be able to reproduce it in order to investigate it. Thank you Jayesh Viradiya Adobe CF Team Hi Nathan, In the repro case provided by you, I could notice that you were trying to use an Invalid attribute(linkhref) for the GUID element. GUID could have only one Optional element that is "isPermaLink". Check RSS 2.0 spec for more information. So modify your Code with the following lines at appropriate places and it should work fine. Although there is a bug that IsPermaLink acts as mandatory attribute as of now. We are tracking that bug. <cfset myStruct.item[i].guid = structnew()> <cfset myStruct.item[i].guid.isPermaLink="YES/NO(anyone)"> <cfset myStruct.item[i].guid.value = "http://www.google.com"> Thanks Jayesh Viradiya Adobe CF Team Hi Nathan C. Smith Could you please isolate the code which throws the Null Pointer exception and post it here or send it to me at "jayvir@adobe.com" for us to be able to reproduce it in order to investigate it. Thank you Jayesh Viradiya Adobe CF Team Jayesh, I was able to create a NPE by not supplying isPermaLink: <cfscript> // Create the feed data structure and add the metadata. myStruct = StructNew(); mystruct.link = "http://www.cnn.com"; myStruct.title = "CNN"; mystruct.description = "This... is... CNN"; mystruct.pubDate = Now(); mystruct.version = "rss_2.0"; /* Add the feed items. A more sophisticated application would use dynamic variables and support varying numbers of items. */ myStruct.item = ArrayNew(1); myStruct.item[1] = StructNew(); myStruct.item[1].description = StructNew(); myStruct.item[1].description.value = "Desc 1"; myStruct.item[1].link = "http://www.cnn.com/1.cfm"; myStruct.item[1].pubDate = Now(); myStruct.item[1].title = "Title one"; myStruct.item[1].guid = structNew(); myStruct.item[1].guid.value = "http://www.foo.com"; myStruct.item[2] = StructNew(); myStruct.item[2].description = StructNew(); myStruct.item[2].description.value = "Desc 2"; myStruct.item[2].link = "http://www.cnn.com/2.cfm"; myStruct.item[2].pubDate = Now(); myStruct.item[2].title = "Title Two"; </cfscript> <!--- Generate the feed and save it to a file and variable. ---> <cffeed action = "create" name = "#myStruct#" overwrite = "yes" xmlVar = "myXML"> <cfdump var="#xmlParse(myXML)#"> ----- Excess quoted text cut - see Original Post for more ----- > I believe href will then be used for the value. If not, try > link perhaps. > If I work backwards and read a feed into cffeed there is a "linkhref" in the guid struct. I'm pretty sure I tried that one going the other direction though. -Nate I found it. If you look in the CFML 8 Reference, page 191, there is a giant table that lists all of the query columns and what they mean. If you find ID, you will see that it means GUID for RSS 2. I specified ID for my test and it worked fine, I got a GUID in my feed. (But note I tested with a query, not a struct.) ----- Excess quoted text cut - see Original Post for more ----- OK, According to Jayesh Viradiya (Thanks Jayesh!) To use the guid value in cffeed it will look something like this: <cfset myStruct.item[i].guid = structnew()> <cfset myStruct.item[i].guid.isPermaLink="YES/NO(anyone)"> <cfset myStruct.item[i].guid.value = "http://www.google.com"> /me goes to try it out. -Nate ----- Excess quoted text cut - see Original Post for more ----- Jayesh - what about my comment about using "ID" in query? It worked there. And the docs plainly say that ID means GUID in query data. If ID works for query, but GUID works for struct, then I'd consider that a bug - and confusing at that. ----- Excess quoted text cut - see Original Post for more ----- I've confirmed that what you say is right Jayesh - guid works when you create the feed via struct. So can you confirm if the following statement is correct: When creating a feed via a query, you should name your columns based on what the PDF describes, ie, ID==GUID. When creating a feed via a struct, you use the literal values. (Frankly, I don't know how much CFFEED helps you at this point as you are doing more work than you would if you generated the XML by hand. ;) ----- Excess quoted text cut - see Original Post for more ----- Yes Ray....What you have mentioned is correct. For Query, ID=GUID. And While creating a feed via struct, we use the literal values as in the specs. For reading feeds into queries we wanted to provide a common predefined query format which stands for both RSS 2.0 and ATOM 1.0 , hence the query column names are different than the actual respective syndication formats. And hence in the doc you could see the Mappings for RSS2/ATOM1 with the predefined Query Columns name. Thanks Jayesh Viradiya Adobe CF Team I've confirmed that what you say is right Jayesh - guid works when you create the feed via struct. So can you confirm if the following statement is correct: When creating a feed via a query, you should name your columns based on what the PDF describes, ie, ID==GUID. When creating a feed via a struct, you use the literal values. (Frankly, I don't know how much CFFEED helps you at this point as you are doing more work than you would if you generated the XML by hand. ;) ----- Excess quoted text cut - see Original Post for more -----
|
Mailing Lists
|
Latest Fusion Authority Articles
|
||||||