Working with created pages in Composite C1

In my ASP.Net project, which I'm trying to move to Composite, I'm having problems working with non-physical pages.

For simplicity, let's assume that I have an online store, and each category in the database has its own URL. (e.g.: / myshop / clothes)

In an ASP.NET project, such a URL will be redirected to the Category.aspx page, which processes the request and reads the contents of the category from the database.

The composite seems to be more focused on "real" pages, what would be the best way to implement something like this? (especially routing)

And: Is there a way to get these generated pages to work with modules like Navigation.Path?

+4
source share
1 answer

To create menus and breadcrumbs you will need to deal with this yourself, eventually using the SiteMap.Resolve event on SiteMapProvider to dynamically insert your "nonexistent" pages.

Regarding routes in C1, there is functionality that analyzes the URL on the first “real page” and gives you the extra part of the URL that you can work with. Suppose that / myshop was your store page, and the user requested / myshop / clothes, then there would still be / myshow, which will be executed, and you would put a code there that will process your categories.

The code that will retrieve the "clothes" on your myshop page will be Composite.Core.Routing.Pages.C1PageRoute.GetPathInfo() , and to let C1 not throw a 404 error, you call Composite.Core.Routing.Pages.C1PageRoute.RegisterPathInfoUsage() so that C1 knows that “clothing” was a valid category.

Read more about the API for it here .

If you need to handle different situations when a category is selected, and when the user simply clicks / myshop directly, you must configure the MyShop page to use a specific template, and there you will wrap the <rendering:contentplaceholder> element in a function that has some else logic -if. If no category is selected, print the contents of <rendering:contentplaceholder> , otherwise search by category and print other content.

+5
source

Source: https://habr.com/ru/post/1383337/


All Articles