Programmatically populate the Code Snippet dropdown - ISSUE

Last post 06-01-2011, 12:27 PM by Eric. 5 replies.
Sort Posts: Previous Next
  •  05-13-2011, 11:29 AM 67566

    Programmatically populate the Code Snippet dropdown - ISSUE

    I am using CuteEditor v6.6
     
    I have 3 editors on my page and they are called "Editor1", "Editor2", and "Editor3".
    I modified the custom code drop down to contain 3 elements ("Code1", "Code2", and "Code3").
    I want to be able to programaticly define what "Code Snippets" appear in each of my 3 editors.
    According to your documentation I am suppose to be able to do the following:
    Editor1.CodeSnippetDropDownMenuNames = "Code1, Code2, Code3"  
    Editor1.CodeSnippetDropDownMenuList = "Code1, Code2, Code3"  
     
    Editor2.CodeSnippetDropDownMenuNames = "Code1"  
    Editor2.CodeSnippetDropDownMenuList = "Code1"  
     
    Editor3.CodeSnippetDropDownMenuNames = "Code3"  
    Editor3.CodeSnippetDropDownMenuList = "Code3"  
     
    When I do this, the correct code snippets appear in the drop down for each of the editors, but when I try and select Code3 in Editor3, it does not insert the actual code, but inserts just the text "Code3".
     
    Why would it insert the name of the code snippet instead of the actual code?
     
    If I list all 3 code snippets in the drop downs for each of the 3 editors, then when I select the different code snippet from the drop down for any of the editors, the correct code is inserted. We really need to be able to custom the code snippet for each of the editors on our page. How can we do this?
     
    Sorry for all the red text, but your editor was not letting me change the text back to black. I was getting an error that the script was causing an error in my IE browser.
  •  05-20-2011, 9:23 AM 67637 in reply to 67566

    Re: Programmatically populate the Code Snippet dropdown - ISSUE

    Dear demmett,
     
    Please refer to the following snippet:
    <!-- #include file = "cuteeditor_files/include_CuteEditor.asp" -->
    <html> 
        <head> 
     </head>
        <body>  
      <form name="theForm" method="post">
      <h1>Multiple Editors Example</h1>
      <br>
      <%
       dim content
       content =  "<P><FONT color=#cd0000><b>This paragraph will be edited by the first instance...</b> </FONT></P>"    
      
       Dim editor
       Set editor = New CuteEditor  'Create a new editor class object     
         
       'Set the ID of this editor class
       editor.ID = "Editor1"
       'The toolbar items needed to be disabled going to this string. Example DisableItemList="Bold, New, Delete"
       editor.DisableItemList = "Save"   
       editor.CodeSnippetDropDownMenuNames = "Code1, Code2, Code3"  
                editor.CodeSnippetDropDownMenuList = "Code1, Code2, Code3"
       editor.Draw()
       
       Response.Write "<br><br>"
       Dim editor2
       Set editor2 = New CuteEditor  'Create a new editor class object     
       
       editor2.ID = "Editor2" 'Set the ID of this editor class 
       editor2.Height = 350
       editor2.CodeSnippetDropDownMenuNames = "Code1"  
                editor2.CodeSnippetDropDownMenuList = "Code1"  
       
       
       editor2.Draw()  
       
       Response.Write "<br><br>"
       Dim editor3
       Set editor3 = New CuteEditor  'Create a new editor class object 
       editor3.ID = "Editor3" 'Set the ID of this editor class 
       editor3.Height = 350
       
       editor3.CodeSnippetDropDownMenuNames = "Code3,CuteSoft"   
       editor3.CodeSnippetDropDownMenuList = "Code3,<font color=red>CuteSoft</font>"
       editor3.Draw()  
       ' Retrieve the data from editor: Request.Form("Editor1")
       %>
       <br>
       <input type="submit" value="Update"  class="button65" NAME="Submit1">
      </form>
     </body>
    </html>
     
    Thanks for asking
  •  05-23-2011, 5:13 PM 67666 in reply to 67637

    Re: Programmatically populate the Code Snippet dropdown - ISSUE

    Ok, so I created a page like you suggested above.
     
    Here is the code on my ASP page:
    =====================================================================================
    <!-- #include virtual = "/contentmanager/CuteEditor_Files_v6_1/include_CuteEditor.asp" -->
    <html>
        <head>
     </head>
        <body>  
      <form name="theForm" method="post">
      <h1>Multiple Editors Example</h1>
      <br>
      <%
       dim content
       content =  "<P><FONT color=#cd0000><b>This paragraph will be edited by the first instance...</b> </FONT></P>"    
     
       Dim editor
       Set editor = New CuteEditor  'Create a new editor class object     
         
       'Set the ID of this editor class
       editor.ID = "Editor1"
       Editor.FilesPath = "/ContentManager/CuteEditor_Files"
       'The toolbar items needed to be disabled going to this string. Example DisableItemList="Bold, New, Delete"
       editor.DisableItemList = "Save"   
       editor.CodeSnippetDropDownMenuNames = "Code1,Code2,Code3"  
       editor.CodeSnippetDropDownMenuList = "Code1,Code2,Code3"
       editor.Draw()
       
       'Response.Write "<br><br>"
       'Dim editor2
       'Set editor2 = New CuteEditor  'Create a new editor class object     
       'editor2.FilesPath = "/ContentManager/CuteEditor_Files"

       'editor2.ID = "Editor2" 'Set the ID of this editor class
       'editor2.Height = 350
       'editor2.CodeSnippetDropDownMenuNames = "Code1"  
       'editor2.CodeSnippetDropDownMenuList = "Code1"  
       'editor2.Draw()  
       
       'Response.Write "<br><br>"
       'Dim editor3
       'Set editor3 = New CuteEditor  'Create a new editor class object
       'editor3.ID = "Editor3" 'Set the ID of this editor class
       'editor3.Height = 350
       
       'editor3.CodeSnippetDropDownMenuNames = "Code3,CuteSoft"   
       'editor3.CodeSnippetDropDownMenuList = "Code3,<font color=red>CuteSoft</font>"
       'editor3.Draw()  
       ' Retrieve the data from editor: Request.Form("Editor1")
       %>
     
       <br>
       <input type="submit" value="Update"  class="button65" NAME="Submit1">
      </form>
     </body>
    </html>
    Here is what I added to the Common.config file under the folder (CuteEditor_Files/Configuration/Shared/Common.config )
    ==================================================================================
                 <item text="Code1">
                    <value><![CDATA[<strong>This is code 1</strong>]]></value>
                    <html><![CDATA[<strong>This is code 1</strong>]]></html>
                </item>
                <item text="Code2">
                    <value><![CDATA[<strong>This is code 2</strong>]]></value>
                    <html><![CDATA[<strong>This is code 2</strong>]]></html>
                </item>
                <item text="Code3">
                    <value><![CDATA[<strong>This is code 3</strong>]]></value>
                    <html><![CDATA[<strong>This is code 3</strong>]]></html>
                </item>
     When I tried the above code, when I clicked on the code snippet "Code1", "Code2", or "Code3", I was just getting "Code1", "Code2", or "Code3" appearing in the editor.
     
    When I removed the code
    editor.CodeSnippetDropDownMenuNames = "Code1,Code2,Code3"
    editor.CodeSnippetDropDownMenuList = "Code1,Code2,Code3"
    I could then select one of the code snippets "Code1" and get the appropriate code in the editor
    "<strong>This is code 1</strong>"
    I am sure I am missing something here, but could not figure it out.
  •  05-25-2011, 10:17 AM 67680 in reply to 67666

    Re: Programmatically populate the Code Snippet dropdown - ISSUE

    Dear demmett,
     
    Please refer to the following code, pleaes compare it with yours:
     
    <!-- #include virtual = "/contentmanager/CuteEditor_Files_v6_1/include_CuteEditor.asp" -->
    <html>
    <head>
    </head>
    <body>
    <form name="theForm" method="post">
    <h1>Multiple Editors Example</h1>
    <br>
    <%
    dim content
    content = "<P><FONT color=#cd0000><b>This paragraph will be edited by the first instance...</b> </FONT></P>"

    Dim editor
    Set editor = New CuteEditor 'Create a new editor class object

    'Set the ID of this editor class
    editor.ID = "Editor1"
    Editor.FilesPath = "/ContentManager/CuteEditor_Files"
    'The toolbar items needed to be disabled going to this string. Example DisableItemList="Bold, New, Delete"
    editor.DisableItemList = "Save"
    editor.CodeSnippetDropDownMenuNames = "Code1,Code2,Code3"
    editor.CodeSnippetDropDownMenuList = "Code1,<strong>This is code 1</strong>,Code3"
    editor.Draw()

    'Response.Write "<br><br>"
    'Dim editor2
    'Set editor2 = New CuteEditor 'Create a new editor class object
    'editor2.FilesPath = "/ContentManager/CuteEditor_Files"

    'editor2.ID = "Editor2" 'Set the ID of this editor class
    'editor2.Height = 350
    'editor2.CodeSnippetDropDownMenuNames = "Code1"
    'editor2.CodeSnippetDropDownMenuList = "Code1"
    'editor2.Draw()

    'Response.Write "<br><br>"
    'Dim editor3
    'Set editor3 = New CuteEditor 'Create a new editor class object
    'editor3.ID = "Editor3" 'Set the ID of this editor class
    'editor3.Height = 350

    'editor3.CodeSnippetDropDownMenuNames = "Code3,CuteSoft"
    'editor3.CodeSnippetDropDownMenuList = "Code3,<font color=red>CuteSoft</font>"
    'editor3.Draw()
    ' Retrieve the data from editor: Request.Form("Editor1")
    %>

    <br>
    <input type="submit" value="Update" class="button65" NAME="Submit1">
    </form>
    </body>
    </html>
     
    Thanks for asking
  •  05-31-2011, 3:56 PM 67751 in reply to 67680

    Re: Programmatically populate the Code Snippet dropdown - ISSUE

    That was it.
    The instructions were not very clear on what you were suppose to place in the
    editor.CodeSnippetDropDownMenuList object
     
    I did not realize you were suppose to be placing the HTML code for each of the items defined in the
    editor.CodeSnippetDropDownMenuNames object.
     
    Thanks for your help.
  •  06-01-2011, 12:27 PM 67765 in reply to 67751

    Re: Programmatically populate the Code Snippet dropdown - ISSUE

    You're welcome.
View as RSS news feed in XML