Replies: 1 comment 2 replies
-
Hi there! This is already the default behavior. When a request is intercepted by the Piranha middleware it tries to find a page or post that matches the requested url. If it's found the middleware will rewrite the request url internally to route of the controller action, or razor page that is responsible for rendering the content type. The only exception to this is that the middleware is designed to pass on additional route parameters to pages and posts so that they can have business logic and/or other actions on them. For example, if you have a page with the permalink In MVC this would mean that if the route defined on the page type was [HttpGet]
[Route("mypageaction/{customParam?}")]
public async Task<IActionResult> MyPageAction(Guid id, string customParam, bool draft = false)
{
...
} However, there's no problem putting standard MVC controllers/actions on routes that is not a child of a permalink of a page/post. For more information, take a look at https://piranhacms.org/docs/master/application/advanced-routing. Best regards. |
Beta Was this translation helpful? Give feedback.
-
Hi,
The https://piranhacms.org/docs/master/basics/startup-options page describes for example how to disable the CMS home page and use a custom non-CMS page:
options.UseStartpageRouting = false;
.Similarly, all CMS pages routing can be disabled:
options.UsePageRouting = false;
If I disable
UsePageRouting
, no page will be served by the CMS. I want the CMS to serve the pages (routes) defined on it but fallback to the site's page implementation in case of the route (page) isn't in the CMS.I couldn't find how to keep the CMS pages enabled (
options.UsePageRouting = true;
) and in case a page doesn't exists in the CMS but a page with the same route exists in the site then render the site's page instead of the CMS page.How can I do that?
Thanks
Beta Was this translation helpful? Give feedback.
All reactions