Table of Contents

Manage Everything With the manage Instance

Warning

This is obsolete code and will stop working soon. Please use newer APIs instead like .cms.run(...)

you are here (click to zoom) - discover the stack

The manage object helps you manage content, allowing you to run(...) commands or to get buttons or toolbars.

How to use

Each content-block (usually a Dnn-Module) has it's own 2sxc-instance, which also gives you a prepared manage-object to work with. Here's an example

<a onclick='$2sxc(this).manage.run("layout")'>layout</a>

this click-event will look up the 2sxc-instance using $2sxc(this), then use the manage-object provided by this to then run the layout command. The layout command opens the change-template dialog.

Here's an example to generate a toolbar from code:

<p class="sc-element">
    mouse over this to see the js toolbar generated by the groups of buttons
    <toolbarsGroups></toolbarsGroups>
</p>

<script>
    var toolbarsGroups = {
        groups: [ 
            { buttons: "layout,more"}, 
            { buttons: "app,zone,more" } 
        ]
    };
        
    $(function(){
        $("toolbarsGroups").each(function(index, element){
            var sxc = $2sxc(element);
            var toolbar = sxc.manage.getToolbar(toolbarsGroups);
            $(element).replaceWith(toolbar);
        });
    });
</script>

The example above has a function which will look for all <toolbarsGroups> tags and replace them with the HTML provided by manage.getToolbar(...).

How it works

Basically the manage-property only exists when the user has edit permissions, as 2sxc will automatically include the necessary JS in the page. So if the user doesn't have edit-rights, the .manage property will be undefined. If it does exist, it can be used to do perform these kinds of actions.

Properties and Methods

We try to keep APIs very light, so all the internal properties/objects are not documented and should not be used. These properties and methods can be treated as stable:

  • void .run(...) - used to run a command
  • string .getButton(...) - used to generate HTML for a single button (which when pressed, runs a command) - see buttons and toolbars
  • string .getToolbar(...) - used to generate HTML for a toolbar (with buttons, which run commands) - see buttons and toolbars

You should find some code examples in this demo App

History

  1. Introduced in 2sxc v02.00
  2. Officially released & documented for use in 2sxc v08.06