In this tutorial, you will learn about Umbraco content apps. By the end of this tutorial, you should have enough knowledge to create one within Umbraco V8. A content app is a fancy term for what is in essence the ability to render a custom screen within the Umbraco backend on a page-level basis. A content app can be accessed whenever a page is opened in the content tree. A content app will render an icon next to the info tab, as seen below.
Clicking on the icon will then load a custom view. Content apps are useful when you want to introduce some custom functionality that is not provided by the CMS out-of-the-box on a per-page basis. For example, you could create a view that displayed all the comments made by site visitors on that page, or, you could create a screen to display metrics for that page from Google analytics.
It is possible to build content apps using C#, or angular.js. I will focus on the C# approach within this tutorial. If you want to use angular instead you can learn more within the Umbraco documentation here.
How To Built A Content App
Step One: To create a content app you will need to create a content app factory. This is done by creating a custom class and making it implement from IContentAppFactory
, like this:
Hopefully, the configuration above should be easy to understand:
View
defines where the associated HTML file should be located within the webrootIcon
defines the icon that gets rendered within the CMS. To see what icons you can use, have a look here.alias
will dictate where the associated files will be locatedActive
should be obvious!
Step Two: The recommended location to store all the files related to the content app is within a dedicated folder inside of the 'app_plugins' folder. The folder name should match the content apps alias. In this example, the folder should be called 'myContentApp'. The example below demonstrates the basic HTML structure that will be required to render some text within a content app view:
Step Three: Finally, in order to register the content app within Umbraco, a custom composer needs to be created. If you are new to components and composers, more information can be found here. The code to create a component is shown below:
With the component defined, do not forget to register it with a composer! These three steps define all the things that are required to render a content app, simple. When you next load Umbraco and open up the backend and go to any document-type, you should see a new icon called 'My Content App' next to the 'info' button.
With the component defined, do not forget to register the component via a composer! With these three steps completed, when you next load the Umbraco backend and navigate to any page, you should see a new icon called 'My Content App' next to the 'info' button.
If you want additional files to load with the content app then you may need to create a package.manifest
file in the plug-ins folder. Within package.manifest
you can associate additional files and meta-data, I won't cover that in this tutorial, however, more information on this process can be found here.
Happy Coding!