10706 Posts in 2388 Topics by 1763 members
|Go to End|
8 March 2011 at 10:53am
I need to output the contents of the SubmittedFormField table as XML so that an external system can parse it. However, I don't seem to be able to write XML tags out in the template because I'm declaring the document type as XML:
<?xml version="1.0" encoding="UTF-8"?>
...and the browser is seeing
<% control OutputXML %>
as malformed XML tags. I'm thinking there's probably some sort of built in method to do this in Silverstripe? I'll also need to customize the tags that go around the name/value pairs in the SubmittedFormField table. How do you output XML to the front end in SS?
8 March 2011 at 1:32pm
I haven't worked with XML very much, but I think you should look at the Silverstripe Google Sitemaps module (comes with the default installation, or check it online here: https://github.com/silverstripe-labs/silverstripe-googlesitemaps)
That module can give you a basic guide on how you can output XML on front end (sorry if its not much help...)
9 March 2011 at 4:43am
Yeah thanks but not really much help. @Willr, the main problem I am having is that each FIELD is a different record rather than each SUBMISSION being a different record. Regardless of whether I return it to the browser as a DataObjectSet somehow XML-ized or whether I return it as a string, there is no way for me to specify a new ID in the code each time I reach a new submission in the recordset. See below for example:
I can do:
But what I need to do is:
@Willr -- How can I send these submission to the front end with each ParentID an individual record instead of each Field? How is this done in HTML in the the Reports tab in Userforms?
9 March 2011 at 10:12pm
@Willr, the main problem I am having is that each FIELD is a different record rather than each SUBMISSION
Well yes, the module has to store each answer as it's own object since the number of submissions changes based on a form. If you want a unique ID for the XML then you can use the SubmittedForm ID. That will be unique and each field will have one.
10 March 2011 at 3:20am
Thanks @willr. Ok, I see now why you've modeled the data in this way - in order to turn it "on its side," as it were, you'd have to know how many fields the user added to the form. So I am getting my resultset like this:
SELECT SFF.ParentID, SFF.Title, SFF.Value, EFF.XMLExportTagName AS TagName FROM SubmittedFormField SFF
JOIN SubmittedForm SF ON SFF.ParentID = SF.ID
JOIN EditableFormField EFF ON SFF.Name = EFF.Name
ORDER BY SFF.ParentID ASC
And I'll just have to shuffle them around in PHP. Thanks again for your help.
|Go to Top|