Find more Examples here

Content Types (FlexView-API)

Version reduced to minimal set of HTML Read Example Description

Description

// Default content type
var contentType = "tour";

// available content types
var contentTypes = [
    "tour",
    "poi",
    "hut",
    "lodging",
    "toptipps",
    "story",
    "skiresort",
    "condition",
    "event",
    "offer",
    "gastro"
];

// grab first key/value pair out of query string (brute force)
var keyValue = location.search.substr(1).split("=");

// is key really called "contentType" and is this content type available ?
if ((keyValue[0]=="contentType") || (keyValue[1] in contentTypes)) {
    contentType = keyValue[1];
}

// find flexview api dom node
var tc = document.getElementsByClassName("oax-top-cont")[0];

// choose dom node to place content type menu in
var pb = tc.parentElement;

// create unordered list
var ul = document.createElement("ul");

// iterate over available content types to create a menu
for(var i=0; i<contentTypes.length; i++) {
    // create list element
    var li = document.createElement("li");
    // create text node with content type name
    var t = document.createTextNode(contentTypes[i]);
    // create element to link each menu entry to a content type
    var a = document.createElement("a");
    a.setAttribute("href", "?contentType=" + contentTypes[i]);

    // add it to list element
    a.appendChild(t);
    li.appendChild(a);

    // add list element to list
    ul.appendChild(li);
}

// create new div element
var div = document.createElement("div");
div.setAttribute("class", "container");

// insert new div into panel body just before flexview api node
pb.insertBefore(div, tc);

// add some explanation to the menu
div.appendChild(document.createTextNode("Please choose a FlexView API content type:"));

// add list as menu
div.appendChild(ul);

// flexview API config object
var conf = {
    frontendtype:   contentType,     // content type chosen by query string
    zoom:           11,
    center:       [ 10.292, 47.546 ]
};

// create flexview API
var fvp = oa.api.flexviewpage( conf );