处理 Composite C1 中生成的页面

发布于 2024-12-18 04:48:09 字数 295 浏览 4 评论 0 原文

在我目前正在尝试迁移到复合的 ASP.Net 项目中,我在处理非物理页面时遇到了麻烦。

为了简单起见,假设我有一个网上商店,并且数据库中的每个类别都有自己的 url。 (例如:/myshop/clothes)

在 ASP.NET 项目中,这样的 url 将被路由到页面 Category.aspx,该页面处理请求并从数据库读取类别内容。

复合材料似乎更关注“真实”页面,实现这样的事情的最佳方法是什么? (尤其是路由)

并且:有没有办法让这些生成的页面与诸如 Navigation.Path 之类的模块一起使用?

In my ASP.Net project which I am currently trying to move to Composite I have trouble with dealing with non-physical pages.

For the sake of simplicity, lets assume I have a webshop and each category in the database has its own url. (for example: /myshop/clothes)

In an ASP.NET project an url like this would be routed to a page Category.aspx that handles the request and reads the category content from the database.

Composite seems to be more focussed on "real" pages, what would be the best way to realize something like this? (especially the routing)

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夏天碎花小短裙 2024-12-25 04:48:09

对于菜单生成和面包屑,您需要自己处理,最终使用 SiteMap.Resolve 事件rel="nofollow">SiteMapProvider 动态挂钩您的“不存在”页面。

关于路由,C1 中有一个功能,可以将 url 解析为第一个“真实页面”,并为您提供可以使用的 url 的多余部分。假设 /myshop 是您的商店页面,并且用户请求 /myshop/clothes,那么执行的仍然是 /myshow,并且您可以在其中放置处理您的类别的代码。

在“myshop”页面上提取“衣服”的代码是 Composite.Core.Routing.Pages.C1PageRoute.GetPathInfo(),并指示 C1 不要抛出 404 错误,您可以调用Composite.Core.Routing.Pages.C1PageRoute.RegisterPathInfoUsage(),让 C1 知道“衣服”是有效的 类别。

请在此处了解有关其 API 的更多信息。

如果您需要处理选择类别时的不同情况,以及当用户直接点击 /myshop 时,您可以将 MyShop 页面设置为使用特定模板,并在其中包装 元素具有某种 else-if 逻辑。如果没有选择类别,则打印出的内容,否则根据类别进行一些查找并打印出一些其他内容。

For Menu generation and bread crumbs you would need to handle it yourself, eventually using the SiteMap.Resolve event on the SiteMapProvider to dynamically hook-in your "non-existing" pages.

Regards to routes, there is a functionality in C1, that parses the url into the first "real page" and hands you the excess part of the url that you can work with. Lets say /myshop was your shop-page, and a user requested /myshop/clothes, then it would still be /myshow that would be executed, and you would put code in there that would handle your categories.

The code that would extract "clothes" on your "myshop" page would be Composite.Core.Routing.Pages.C1PageRoute.GetPathInfo(), and to instruct C1 not to throw a 404 error, you call Composite.Core.Routing.Pages.C1PageRoute.RegisterPathInfoUsage(), to let C1 know that "clothes" was a valid category.

Read more about the API for it here.

If you need to handle different situations for when a category is selected, and when a user just hits /myshop directly, you would set the MyShop page to use a specific template, and in there you would wrap the <rendering:contentplaceholder> element in a function that has some kind of else-if logic. If no category is selected, print out the content of <rendering:contentplaceholder>, otherwise do some lookups based on the category and print out some other content instead.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文