Posted on 15/10/2024 16:54:18
Hi August,
Are you using any custom components other than a screen injector? If not, you shouldn't have to worry about views.
If you are using a custom component, there are a few things you need to make sure of.
- The project file is set to include Razor views and it's set to generate a manifest file
- I've included the updated csproj file below
You can adjust the ring version to the one that you need: Ring1, Ring2, Ring3 or Ring4
- The view is in the correct folder structure: <root of project>/Views/Shared/Components/UiComponentWrapper
- The view is named after the component in the correct way: <Name with namespace>.cshtml
- If the component is MyProject.Components.MyCustomComponent.cs, the file name must be MyProject.Components.MyCustomComponent.cshtml
Full path: <root of project>/Views/Shared/Components/UiComponentWrapper/MyProject.Components.MyCustomComponent.cshtml
I know it's a very long and verbose path and it's something I'd like to change, but it has to be like that for now
- Any static files you need to include, such as JavaScript or CSS, should go into the wwwroot folder -- it's up to you how you want to structure it from there
- Ensure that you're implementing the IRenderingBundle just as the RenderingBundle.cs in the root of the existing project
It seems you're trying to add components to the Form edit screen directly, as you previously mentioned. This will not work due to the issues discussed above. Instead, you should consider adding a button to the FormSettingsEditScreen. If you're trying this out to see how it works with extending screens and creating custom components, I'm 100% for that; I just want to make sure that you're not going down a path that cannot lead to success.
To add a button to the screen, find the layout similar to what you already do. Then call
layout.AddAction(new()
{
Name = "Add campaign",
Icon = Dynamicweb.CoreUI.Icons.Icon.PlusSquare,
NodeAction = OpenSlideOverAction
.To<CampaignSelectPromptScreen>()
.With(new CampaignAttachQuery() { FormId = screen?.Model?.Id })
});
On the CampaignSelectPromptScreen, you create reference a command that can create or update the relation between the form and the campaign. Let me know if you need more information on this.
- Jeppe
Updated csproj file:
<Project Sdk="Microsoft.NET.Sdk.Razor">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<AddRazorSupportForMvc>true</AddRazorSupportForMvc>
<GenerateEmbeddedFilesManifest>true</GenerateEmbeddedFilesManifest>
</PropertyGroup>
<ItemGroup>
<EmbeddedResource Include="wwwroot/**/*" />
</ItemGroup>
<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Dynamicweb.Suite.Ring1" Version="*" />
<PackageReference Include="Microsoft.AspNetCore.Components.Web" Version="8.0.8" />
<PackageReference Include="Microsoft.Extensions.FileProviders.Embedded" Version="8.0.8" />
</ItemGroup>
</Project>