-
Hello team, I am working on a theme project and need to include static CSS files. Following the official documentation at Resources - Orchard Core Documentation, I planned to use the Resource Manifest registration approach. However, I am encountering an issue where I cannot register Environment
Steps Taken
Issue
Expected Behavior
Additional Context
Could you please provide guidance on how to properly register the resource manifest in a theme project? Any examples or references to similar issues would be greatly appreciated. Thank you for your support. Best regards, ResourceManagementOptionsConfiguration.cs using Microsoft.Extensions.Options;
using OrchardCore.ResourceManagement;
namespace OrchardCore.BookingTheme
{
public sealed class ResourceManagementOptionsConfiguration : IConfigureOptions<ResourceManagementOptions>
{
private static readonly ResourceManifest _manifest;
static ResourceManagementOptionsConfiguration()
{
_manifest = new ResourceManifest();
// --- Add Apple Style Definition ---
_manifest
.DefineStyle("bookingtheme-apple-style") // Unique name for your style
.SetUrl("~/OrchardCore.BookingTheme/css/apple-style.css", "~/OrchardCore.BookingTheme/css/apple-style.css") // Path to your CSS file
.SetVersion("1.0.0"); // Optional: Version number
}
public void Configure(ResourceManagementOptions options)
{
options.ResourceManifests.Add(_manifest);
}
}
} Startup.cs using Microsoft.Extensions.DependencyInjection;
using OrchardCore.Modules;
namespace OrchardCore.BookingTheme;
public class Startup : StartupBase
{
public override void ConfigureServices(IServiceCollection services)
{
services.AddResourceConfiguration<ResourceManagementOptionsConfiguration>();
}
} sln file: <Project Sdk="Microsoft.NET.Sdk.Razor">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<AddRazorSupportForMvc>true</AddRazorSupportForMvc>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>
<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="OrchardCore.ResourceManagement" Version="2.1.6" />
<PackageReference Include="OrchardCore.ResourceManagement.Abstractions" Version="2.1.6" />
<PackageReference Include="OrchardCore.Resources" Version="2.1.6" />
<PackageReference Include="OrchardCore.Theme.Targets" Version="2.1.6" />
<PackageReference Include="OrchardCore.ContentManagement" Version="2.1.6" />
<PackageReference Include="OrchardCore.DisplayManagement" Version="2.1.6" />
</ItemGroup>
</Project> |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Please use the following code: using Microsoft.Extensions.DependencyInjection;
using OrchardCore.Modules;
namespace OrchardCore.BookingTheme;
public class Startup : StartupBase
{
public override void ConfigureServices(IServiceCollection services)
{
services.AddTransient<IConfigureOptions<ResourceManagementOptions>, ResourceManagementOptionsConfiguration>();
}
} The |
Beta Was this translation helpful? Give feedback.
Please use the following code:
The
AddResourceConfiguration()
will be a part of OC 3.0.0 If I recall