Create Custom Blocks and Custom Pages Inside module #1830
-
I have a Blog module that includes several pages like "StandardArchive" "StandardPage" and I also have several Custom Block for this module to be placed in the module itself, But when these pages and blocks work properly to be on the main path of the project, |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
I just figured this out today. In a blog post, one of the Piranha authors had an example of a See the solution explorer where I laid this out:
Then, my extensions module that your startup would call to register this: using Argus.Web.Cms.Models;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.FileProviders;
namespace Argus.Web.Cms.Modules;
public static class ModuleExtensions
{
public static IServiceCollection AddPiranhaExtend(this IServiceCollection services)
{
// Add the identity module
App.Modules.Register<Module>();
App.Blocks.Register<RawHtmlBlock>();
App.Modules.Manager().Scripts.Add("~/manager/js/rawhtml-block.js");
App.Modules.Manager().Styles.Add("~/manager/js/rawhtml-block.css");
return services;
}
public static IApplicationBuilder UsePiranhaExtend(this IApplicationBuilder builder)
{
// Add the embedded resources. All of the javascript files in the assets folder will be served
// from the below request path, in our case this is only js files.
return builder.UseStaticFiles(new StaticFileOptions
{
FileProvider = new EmbeddedFileProvider(typeof(ModuleExtensions).Assembly, "Argus.Web.Cms.Modules.assets"),
RequestPath = "/manager/js"
});
}
} Startup.cs
|
Beta Was this translation helpful? Give feedback.
I just figured this out today. In a blog post, one of the Piranha authors had an example of a
RawHtmlBlock
block which I found very useful. The tricky part was just figuring out where the files went in the Razor Library and then getting the right build action for them.See the solution explorer where I laid this out:
rawhtml-block.css
=> Embedded resource (do not copy)rawhtml-block.js
=> Embedded resource (do not copy)RawHtmlBlock.cshtml
=> Content (do not copy)Then, my extensions module that your startup would call to register this: