简体   繁体   English

如何在Sitecore中创建新页面

[英]How to create a new page in Sitecore

I need to add a page in Sitecore: 我需要在Sitecore中添加一个页面:

  • abc.com/link1?id=1*something=BLABLA
  • abc.com/link2?id=2*something=BLABLA
  • abc.com/linkN?id=N*something=BLABLA

All of the links above represent a single page, which in turn serves the user a template based on link1 , link2 ... linkN . 上面的所有链接都代表一个页面,而这个页面又为用户提供了一个基于link1link2 ... linkN的模板。

This is also a link that may prove helpful Learn sitecore . 这也是一个可能有用的链接学习sitecore Very succinctly, my general approach is to create a template, create a page under content, then assign a layout that links it up to asp.net stuff. 非常简洁,我的一般方法是创建一个模板,在内容下创建一个页面,然后分配一个布局,将它链接到asp.net的东西。

It sounds to me like you can just create three new items ( link1 , link2 , and linkN ). 听起来像你可以创建三个新项目( link1link2linkN )。 These items can share the same "base" template that contains everything they have in common (Layout, common/shared Controls, etc.). 这些项目可以共享相同的“基础”模板,其中包含它们共有的所有内容(布局,公共/共享控件等)。 Form there, if you need each one to be slightly different, you can create a new set of templates for each item that inherit from the base template (recommended), or modify the presentation details on each item directly. 从那里开始,如果您需要每个项目略有不同,您可以为从基础模板继承的每个项目创建一组新模板(推荐),或直接修改每个项目的演示文稿详细信息。

That said, if you truly need a single item that accepts multiple routes and query strings, you have a few options: 也就是说,如果你真的需要接受多种途径和查询字符串中的单个项目 ,你有几种选择:

  1. If the item exists at the root of your site, you can create a single item and make Aliases for any other names you wish to route to the item. 如果项目存在于您网站的根目录中,您可以创建单个项目,并为您希望路由到该项目的任何其他名称创建别名 For example, an item named link can have aliases for link1 , link2 , linkN , etc. The query strings will work across all aliased pages. 例如,名为link的项可以包含link1link2linkN等的别名。查询字符串将适用于所有别名页面。 Using this approach, you would not be changing "Layout" as you described. 使用这种方法,您不会像您所描述的那样更改“布局”。 Rather, your Layout (or one or more Sublayouts) would react to the available query strings and offer up different views and/or behavior. 相反,您的布局(或一个或多个子布局)将对可用的查询字符串做出反应,并提供不同的视图和/或行为。 I like to call this making the Sublayout "smarter" :) 我喜欢称之为Sublayout“更聪明”:)

  2. If you need a more robust solution that allows routing beyond the root of the site, you may want to look into extending the UrlResolver in the HttpRequest pipeline. 如果您需要一个更强大的解决方案,允许路由超出站点的根目录,您可能需要考虑在HttpRequest管道中扩展UrlResolver。

If you want to use a single item to handle all the three links, you can also use a wildcard item in which you read the querystring from the httpcontext and do whatever you want to do based on the querystring. 如果要使用单个项目来处理所有三个链接,还可以使用通配符项,从中读取httpcontext中的查询字符串,并根据查询字符串执行您想要执行的任何操作。

Another thing that comes to my mind when looking at your question is: What do you want to achieve with the querystings? 在查看您的问题时,我想到的另一件事是:您希望通过查询来实现什么? At might be me but this looks a bit like you are trying to create a Sitecore site with the techniques of joomla (or other cms) based urls. 可能是我,但这看起来有点像你正在尝试使用基于joomla(或其他cms)的网址技术创建Sitecore网站。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM