Hello!
Trying to create a page for a department to easily manage content for a specific metadata on a set of pages.
Right now, just trying to produce a listing which pulls the course name in H2 and Entry Criteria underneath. Sure it can be done via asset listing, and new value could be saved by trigger, but curious to play around with the JS API.
I'm supplying the root id to js_api.getChildren, which fetches attributes for all courses. I need to pick up the asset-id to then fetch the metadata – stuck on this bit.
Code below results in a listing of Course names. Entry criteria returns 'undefined' for all courses. However, console.log line does retrieve the content, so just need help getting this content on the page.
function printCourses(course) { var msg = ''; for (var i in course) { msg += "<h2>" + course[i].name + "</h2>"; js_api.getMetadata({ "asset_id": course[i].id, "dataCallback": function(data) { console.log(data.entry_criteria); msg += data.entry_criteria; } }); } var content = document.getElementById("asset_area"); content.innerHTML = msg; }js_api.getChildren({
“asset_id”:2231,
“levels”:1,
“type_codes”:[
“page_standard”
],
“link_types”:[
“SQ_LINK_TYPE_2”
],
“get_attributes”:1,
“dataCallback”: printCourses
})