mkdir1995
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-15-2018
01:24 PM
How to add custom field to Node?
I can't seem to find anything on the forum or in the SDK on how to add a custom field into the node object. For example, a roSGNode is set up like this:
Now, using my server data, I know I can program my content with the corresponding Content Meta Data. I can set the TITLE, URL, DESCRIPTION, id etc because that is what is provided to me in the roSGNode. What if I need custom fields in order to continue setting up my application? For example, I need to add a TYPE right under the 'URL' in the node above.
I tried using .addFields() but that didn't seem to work.
Any help is greatly appreciated since I've been trying for a few days and can't figure it out. Thanks!
<Component: roSGNode> =
{
change: <Component: roAssociativeArray>
focusable: false
focusedChild: <Component: roInvalid>
id: ""
DESCRIPTION: ""
HDBACKGROUNDIMAGEURL: ""
HDPOSTERURL: ""
RELEASEDATE: ""
STREAMFORMAT: ""
TITLE: "cartoon 1"
URL: ""
}
Now, using my server data, I know I can program my content with the corresponding Content Meta Data. I can set the TITLE, URL, DESCRIPTION, id etc because that is what is provided to me in the roSGNode. What if I need custom fields in order to continue setting up my application? For example, I need to add a TYPE right under the 'URL' in the node above.
I tried using .addFields() but that didn't seem to work.
Any help is greatly appreciated since I've been trying for a few days and can't figure it out. Thanks!
6 REPLIES 6
tim_beynart
Channel Surfer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2018
09:52 AM
Re: How to add custom field to Node?
you extend the node, then you can add any fields you want.
For example:
For example:
<?xml version="1.0" encoding="utf-8" ?>
<component name="media_item" extends="ContentNode">
<interface>
<field id="thumbnail" type="string" />
<field id="content_type" type="string" />
<field id="title" type="string" />
<field id="entitlement" type="string" />
<field id="guid" type="string" />
<field id="duration" type="float" />
<field id="category" type="string" />
<field id="ratings" type="array" />
<field id="genres" type="array" />
<field id="daypart" type="string" />
<field id="program" type="string" />
<field id="episode" type="string" />
<field id="season" type="string" />
<field id="airdate" type="string" />
<field id="callsign" type="string" />
</interface>
</component>
tim_beynart
Channel Surfer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2018
09:55 AM
Re: How to add custom field to Node?
it's covered, briefly, in step 6 of this lesson:
https://github.com/learnroku/crash-cour ... Lesson3.md
https://github.com/learnroku/crash-cour ... Lesson3.md
NB_
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2018
01:10 PM
Re: How to add custom field to Node?
Or you can add fields dynamically, without extending-through-XML/compilation - as simple as:
myNode.addFields({myNewField: value1, more2: 7})
mkdir1995
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2018
08:55 AM
Re: How to add custom field to Node?
I ended up using addFields, it does exactly what I need to do without the extra XML confusion. Works like a charm. Thanks all!
tim_beynart
Channel Surfer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-20-2018
12:38 PM
Re: How to add custom field to Node?
well damn, that is much easier
norcaljohnny
Roku Guru
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-22-2018
11:10 PM
Re: How to add custom field to Node?
"tim_beynart" wrote:
it's covered, briefly, in step 6 of this lesson:
https://github.com/learnroku/crash-cour ... Lesson3.md
Hey Tim, I read that course and it was a goodie. You provide a lot of good information that is clear and to the point.
Cheers 🙂