The mooized code is as simple as this:
node_id = 2;If you want to use it to fill select box options, following code will do the trick:
var jsonRequest = new Request.JSON({url: "http://site.com/content/treemenu/"+node_id, onComplete: function(result){
alert(result.children);
}}).get();
node_id = 2;
var jsonRequest = new Request.JSON({url: "http://site.com/content/treemenu/"+node_id, onComplete: function(result){
element = $('selectelement');
$each(result.children,function(item) {
element.options[element.options.length] = new Option(item.name,item.node_id);
});
}}).get();
To get this working correctly you need to allow contentstructure menu for your public site access and define classes you want to fetch (like this)
[TreeMenu]in contentstructuremenu.ini.append.php file.
Dynamic=enabled
ShowClasses[]=article
Žádné komentáře:
Okomentovat