https://discord.umbraco.com logo
#package-development
I already posted this question to `help-
# package-development
g

gregor.tusar

02/05/2024, 8:05 AM
I already posted this question to
help-with-umbraco
(https://discord.com/channels/869656431308189746/1201498769997443122) but I'll try also here: We are building a package that has a custom .html view for property editor. We added the .html file under wwwroot/App_Plugins/Company.Plugin/customView.html. The package gets installed in solution successfully but after we try to select this view for a element of a block grid, the custom view cannot be selected from the file tree. It looks like the content of the wwwroot does not actualy copy to the output directory. However, if the view is hardcoded in a Data Editor it works somehow. It is also accessible via URL. How to select the custom property editor view for a data editor if it is installed via plugin? https://cdn.discordapp.com/attachments/882984798719729704/1203974583963746344/image.png?ex=65d30bb5&is=65c096b5&hm=a7f68b28f99634b406fd33dfeeb1225cdd5eb2ac2fe0d0471b9de157da063701&
d

d_inventor

02/05/2024, 11:35 AM
Hi there! What sort of library do you use for your package? Is it a Razor Class Library? If you build your project locally with the package installed, can you find the physical file in wwwroot in your file explorer?
g

gregor.tusar

02/05/2024, 12:57 PM
Yes, it is RCL package. I see the the physical file in package RCL wwwroot, but not in the wwwroot of the Site project, that has this package installed.
I could add
.targets
or
.csproj
command, that would copy the
.html
to site's
wwwroot
folder, but I think this is not ok, since there are then 2 files in the solution that are basically the same.
For
DataEditor
that has fixedly defined
EditorView
inside
Copy code
[DataEditor(EditorAlias, EditorTypeEnum, EditorName, EditorView, Group = EditorGroup, Icon = EditorIcon, ValueType = EditorValueType)]
public class MyDataEditor : DataEditor
{
    internal const string EditorView = "~/App_Plugins/MyPlugin/MyDataEditor.html";
    ...<omitted for brevity>...
}
this finds the view normally, even though it is not physically in sites
wwwroot
or
App_Plugins
folders, but only in plugins project
wwwroot
folder.
m

mistyn8

02/06/2024, 9:51 AM
Could it be that you've got a period in your plugin name? Rename to CompanyPlugin, perhaps the tree renderer is baulking at a suposed folder name with a period?
d

d_inventor

02/06/2024, 10:05 AM
The menu that you're showing here uses a physical file system provider. For that reason, the file doesn't show up here, because the file isn't in the physical location. If you want your file to show up here, you'd have to use code to add it to the list or use the targets file to copy the physical file into your project
I've done it before with code, because target files are kinda wonky in my opinion.
Copy code
csharp
public class BlockPreviewTreeRenderingNotification : INotificationHandler<TreeNodesRenderingNotification>
{
    public void Handle(TreeNodesRenderingNotification notification)
    {
        if (!string.Equals(notification.TreeAlias, "staticFiles", StringComparison.Ordinal)
            || !string.Equals(notification.Id, Constants.System.RootString, StringComparison.Ordinal)) return;

        notification.Nodes.Add(new TreeNode("App_Plugins%2fblockpreview%2fblock-preview.html", null, null, null)
        {
            HasChildren = false,
            Icon = "icon-document",
            Name = "block-preview.html",
            ParentId = "-1",
        });
    }
}
g

gregor.tusar

02/07/2024, 7:55 AM
Thanks we'll give it a try. Do you think it is a viable option to create a custom FileSystemProvider, that would also include packages wwwroot folders? https://docs.umbraco.com/umbraco-cms/extending/filesystemproviders
d

d_inventor

02/07/2024, 11:46 AM
Can't say for sure, I remember there was something funky going on here, but I can't remember exactly what it was.
g

gregor.tusar

02/13/2024, 2:51 PM
I managed to solve it with custom tree, find the code below: Switch original controller with this one
Copy code
csharp
    public class TreeComposer : IComposer
    {
        public void Compose(IUmbracoBuilder builder)
        {
            builder.Trees().RemoveTreeController<StaticFilesTreeController>();
            builder.Trees().AddTreeController<CustomStaticFilesTreeController>();
        }
    }
https://cdn.discordapp.com/attachments/1203974584227991552/1206975885261938698/message.txt?ex=65ddf6e3&is=65cb81e3&hm=8bad0d5ebccf4ad985a1e0da2d1ae3dea5f8d735869a5a75b9abeb66b76f98cc&