Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Rhys Mitchell 28 posts 195 karma points
    May 18, 2017 @ 09:50
    Rhys Mitchell
    0

    Extending Rich Text Editor (TinyMCE) / Working with Package Actions

    Hi Umbracians,

    I recently finished writing a TinyMCE extension that allows our content editors to add Bootstrap buttons into their Rich Text Editor. I want to make it available as a package, as it's really quite a useful addition.

    In order for me to package this up, I need the ability to edit config/tinyMceConfig.config on the fly using Package Actions.

    All the forum posts etc thus far point me to the official documentation that appears to have been taken down.

    So, in short.. how do I edit this file during install?

    Thanks in advance, I look forward to putting out more packages in the future!

  • Marcin Zajkowski 112 posts 585 karma points MVP 7x c-trib
    May 18, 2017 @ 10:16
    Marcin Zajkowski
    0

    Check: https://our.umbraco.org/projects/backoffice-extensions/package-actions-contrib/

    Maybe also think about choosing any other way of doing it if you want to distrubute your package e.g. via NuGet. You can change the configuration on ApplicationStartup events for example in your own DLL shipped with it.

  • Rhys Mitchell 28 posts 195 karma points
    May 18, 2017 @ 10:24
    Rhys Mitchell
    0

    Hi Marcin,

    Thanks for replying so fast!

    I had seen this package a little bit earlier, I didn't commit to it though because the wiki link is dead. In the spirit of moving forward, I am to include the PackageActionsContrib.dll and presumably from there I inherit from ApplicationStartup in a .cs file that's within my package directory?

    I have been on an Umbraco project for only a few months, so I am sorry if I need a bit of hand-holding. Thanks again!

  • Marcin Zajkowski 112 posts 585 karma points MVP 7x c-trib
    May 18, 2017 @ 10:27
    Marcin Zajkowski
    0

    Hey, np!

    You don't need this PackageActionContrib.dll if you won't be doing nothing using Package Actions.

    Check: https://our.umbraco.org/documentation/reference/events/Application-Startup for a reference regarding events in Umbraco. You can hook up to any event and made a change in the file for the first time.

    You can also check migrations well described by Cultiv here: https://cultiv.nl/blog/using-umbraco-migrations-to-deploy-changes/.

    I hope it will help you :)

  • Rhys Mitchell 28 posts 195 karma points
    May 18, 2017 @ 10:32
    Rhys Mitchell
    0

    I am familiar with subscribing to ApplicationStartup, as I have written some code that automatically generates required nodes in the tree. My new and improved question is, is this okay to build a .cs class within the package directory? Is there any convention to doing this?

    e.g. ~/App_Plugins/[Plugin_Name]/RegisterEvents.cs

  • Marcin Zajkowski 112 posts 585 karma points MVP 7x c-trib
    May 18, 2017 @ 10:39
    Marcin Zajkowski
    0

    Aaargh, no, it shouldn't be placed there.

    If you're developing single website and it's a web application which is compiled, you can place it in any directory on your site and it will be stored in the DLL.

    If you're developing package as a stand-alone application, then you can create a class library inside of it, reference Umbraco.Core and keep this class there. Then just ship the DLL to your website and it will take care of the rest.

    You can also keep the C# code (classess etc.) in App_Code directory, which is compiled on the fly if you don't want to create any other DLLs.

  • Rhys Mitchell 28 posts 195 karma points
    May 18, 2017 @ 10:45
    Rhys Mitchell
    0

    My situation is kind of both, I am developing a single website but have in doing so developed a few handy things I can package up for the community. If I were to add a class library, that would sit alongside my current project is that right? So I cannot edit config/tinyMceConfig.config directly from the App_Plugins directory?

    Thanks for all your help, I am just looking for the tidiest way to contribute :)

  • Marcin Zajkowski 112 posts 585 karma points MVP 7x c-trib
    May 18, 2017 @ 10:52
    Marcin Zajkowski
    100

    If you will package the library as an Umbraco / NuGet package you are able to place your items inside the App_Plugins (views, js code, css or anything else) and also add DLL to the existing Umbraco project. The logic will be inside of the DLL and will have access to the filesystem on your application. You can then modify whatever you want, so then you can access /config/tinymce.config and modify specific property / setting.

    Check how others are doing it, eg.:

    etc.

  • Rhys Mitchell 28 posts 195 karma points
    May 18, 2017 @ 10:59
    Rhys Mitchell
    1

    Brilliant,

    Thanks a lot Marcin - I have marked your answer as the solution.

  • Marcin Zajkowski 112 posts 585 karma points MVP 7x c-trib
    May 18, 2017 @ 11:00
    Marcin Zajkowski
    0

    Thank you. Happy coding!

  • Rhys Mitchell 28 posts 195 karma points
    May 18, 2017 @ 11:55
    Rhys Mitchell
    0

    Okay, so I have created a new class library alongside my website's solution. Subscribed to ApplicationEventHandler and attempted to open the required config file.

    Being that it's essentially a separate project, the breakpoint is not hit. Am I missing something? Possibly something really silly :) Screenshot

  • Marcin Zajkowski 112 posts 585 karma points MVP 7x c-trib
    May 18, 2017 @ 12:05
    Marcin Zajkowski
    0

    Hm did you reference this library in your web application? Are you attaching the debugger to the IIS / IIS Express process? :)

  • Rhys Mitchell 28 posts 195 karma points
    May 18, 2017 @ 12:09
    Rhys Mitchell
    0

    I added the ReBootstrapButtons Class Library to the Project Dependencies, I haven't touched the debugger.. this might be where I am going wrong.

  • Marcin Zajkowski 112 posts 585 karma points MVP 7x c-trib
    May 18, 2017 @ 12:11
    Marcin Zajkowski
    0

    Hmm you don't need to register additional event handler there. Check if you debugger stops on the ApplicationStarted method and execute your code there.

  • Rhys Mitchell 28 posts 195 karma points
    May 18, 2017 @ 12:26
    Rhys Mitchell
    0

    I can confirm that the debugger still ignores the breakpoint :(Screenshot

Please Sign in or register to post replies

Write your reply to:

Draft