0
votes

What I'm trying to do

I'm writing an extension to the sitecore rich text editor that works in the following manner.

  1. The User clicks a button on the rich text editor toolbar that was added by the extension.
  2. The extension javascript builds a url that includes the Item ID, Language, Version and database. This URL is used to open a rich editor dialog.
  3. The dialog shows options that are relevant to the current item

The Problem

I can't find anyway of detecting the following important information about the item that is currently being edited. Can someone tell me how to get this information in javascript:

  • The Version number of the item that is being edited.
  • The database in which the item resides

Example

RadEditorCommandList["MyCommand"] = function (commandName, editor, tool) {
    var dialogUrl = "/sitecore%20modules/MyPluginModule/RichEditorDialog.aspx?";
    dialogUrl+= "Id=" + scItemID ;
    dialogUrl+= "&language=" + scLanguage; 

    //////////////////////////////////////////////////////////
    // UNKNOWN -- where do I get this information from?
    //////////////////////////////////////////////////////////
    dialogUrl+= "&database=UNKNOWN"; 
    dialogUrl+= "&version=UNKNOWN";

    editor.showExternalDialog(
        dialogUrl, 
        null,
        500, // width
        200, // height
        function(sender, data) {
           updateRichTextEditorWithSelectedData(editor, data);
        },
        null, // callback args
        "Dialog Title",
        true, // modal
        Telerik.Web.UI.WindowBehaviors.Default,
        false, // showStatusBar
       true  // showTitleBar
    );
 };
1

1 Answers

0
votes
  • Is this javascript on an aspx page? If so, you could fetch the version number using <%= Sitecore.Context.Item.Version.Number%> and database using <%= Sitecore.Context.Database.Name%>
    • If not, you could create a small service method and make an ajax request with the itemid you have (scItemID) and get this same information back from the service as a json object and use the same. In this case, if you are not able to access the item using the current context, you should be able to search both core and master DB in the server side code with the item guid and return response accordingly

Hope this helps.