0

我想知道是否可以使用 kentico 宏(不一定编码自定义宏)来访问重写的 URL 路径的一部分。

示例:http ://www.mysite.com/Category/Subcategory/

我想获得最后一部分(子类别),以便我可以动态过滤内容。我想使用宏的原因是根本不必拥有 20 多个不同的页面模板,这样我就可以拥有不同的 Web 部件属性。

4

2 回答 2

0

假设您使用的是门户模板,并且您不希望父级上出现“所有子类别中的所有项目”列表:

  1. 在父页面上创建文章列表 Web 部件 - 所有子类别的父级。
  2. 将 Web 部件设置Path/{0}/{1}/{2}/%(例如,如果您的路径是 /Home/Parent/Subcategory)或适合您的环境的类似内容。
  3. Inherit对所有子类别页面使用页面模板的默认设置。

这不会在父页面上显示任何内容,子类别将仅显示其下的文档。注意:如果您希望子类别项目在用户向下挖掘时有自己的视图/{0}/{1}/{2}/item,您可能需要通过更改模板继承或 Web 部件上的文档类型或类似的方式进行过滤,如果您不希望整个子类别-类别列表也显示在项目特定页面上。

于 2011-12-05T16:56:20.567 回答
0

You can create a custom macro or, you can also use the string operations which are allowed within macros. Please see http://devnet.kentico.com/docs/6_0/devguide/available_macro_methods.htm#string_methods (and you can e.g. use the EndsWith or TrimStrart or something similar).

However, I think the best way would be to create a custom macro which will exactly fit. There might be some combination of macros and macro functions - but I think it is faster just to code a custom one which will cover your need 100%.

Also, you can take a look on the K# if there is something that will fit - http://devnet.kentico.com/docs/6_0/devguide/ksharp_syntax.htm

于 2011-12-08T09:13:23.520 回答