I wanted to have my package custom tab on each content page, in which I can add my functionality further.
Something like this:
There are much examples of how to add section in dashboard etc.
Can anyone guide me in this direction.
Is Umbraco give support to add custom tab through dynamic code.
You have to create a document type in your package that includes your Custom Tab and then use ContentTypeService to get all Content types which you want to display this tab and call .AddContentType(IContentTypeComposition contentType) method for each of them.
Hi Pawel,
I am able to create tabs in each document type. But when I see the document type in backoffice UI. The delete icon is there against each property of the tab.
Its very easy to delete it. So what if user just delete my custom property in my custom tab?
I want this custom tab without delete option in front-end UI.
It will only get delete, when the package get uninstalled.
My apologizes if I missed any of your point, but now I am looking only for adding custom tab without delete option in UI.
you can't disable deleting of the properties but if you use Composition it won't be possible from Content Page view (it will work exactly as on the screenshot you've posted).
So the 'Custom Tab' will be a part of composited document type, not Content Page document type
I think it's not possible because each document type can be used as a composition in another document type. What you can do is to loop through Content Types and check which ones are used as a composition by .CompositionIds()
Custom tab on content pages
I wanted to have my package custom tab on each content page, in which I can add my functionality further. Something like this:
There are much examples of how to add section in dashboard etc. Can anyone guide me in this direction. Is Umbraco give support to add custom tab through dynamic code.
Hi Amna,
Try to have a look at this video from Umbraco TV
https://umbraco.tv/videos/umbraco-v7/implementor/fundamentals/document-types/tabs-and-properties/
So you will need to find the document type for the home page in Settings Section --> Document Types. And then follow the video from Umbraco TV
Hope this helps,
/Dennis
This is a way of adding a tab from Document type section in backoffice.
I am creating a package and wanted to add tab dynamically when package get installed. I am looking for code to add dynamic tabs in each content page.
I wanted to achieve same thing you mentioned, but programmatically
Hi Amna,
Okay then you should have look at our services that we have. https://our.umbraco.org/documentation/Reference/Management/Services
The one that you need to use is the one called ContentTypeService https://our.umbraco.org/documentation/reference/management/services/ContentTypeService
Hope this helps,
/Dennis
Thank you Dennis, its really helpful. I am able to create tabs pro-grammatically.
I wanted to ask, If there is any possibility to disable "delete" functionality in my custom tab against added properties.
Please look into the image for more details:
Hi Amna,
You can't disable the delete option instead, you can use the events either around the doc type save or on app start
Matt
Hi Matt, How can I achieve it in doc save events?
Hi Amna,
You have to create a document type in your package that includes your
Custom Tab
and then useContentTypeService
to get all Content types which you want to display this tab and call.AddContentType(IContentTypeComposition contentType)
method for each of them.you can find more details here Add Content Type Method
Hi Pawel, I am able to create tabs in each document type. But when I see the document type in backoffice UI. The delete icon is there against each property of the tab. Its very easy to delete it. So what if user just delete my custom property in my custom tab?
I want this custom tab without delete option in front-end UI. It will only get delete, when the package get uninstalled.
My apologizes if I missed any of your point, but now I am looking only for adding custom tab without delete option in UI.
Hi Amna,
you can't disable deleting of the properties but if you use Composition it won't be possible from Content Page view (it will work exactly as on the screenshot you've posted).
So the 'Custom Tab' will be a part of composited document type, not Content Page document type
How to check, if existing document type is composite or not?
I am using this to get all:
This is returning all including document type and composite type. Which key will differentiate?
I think it's not possible because each document type can be used as a composition in another document type. What you can do is to loop through Content Types and check which ones are used as a composition by
.CompositionIds()
is working on a reply...