Kentico - 使用日历过滤预订系统事件
在掌握 Kentico CMS 时遇到了很多问题,但我终于接近了。我使用普通的门户引擎并在本地安装上运行 Kentico 5.5 RC2。
我目前有一个事件页面,它使用中继器来显示当前系统上可用的所有事件。我想使用日历来过滤该转发器中的事件。我该怎么办呢?
Having a lot of problems getting to grips with the Kentico CMS, but I'm finally getting somewhere close. I'm using a normal portal engine and running Kentico 5.5 RC2 on a local installation.
I currently have an events page which uses a repeater to display all of the events that are available on the system currently. I want to use a calendar to be able to filter the events in that repeater. How would I go about this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有几种方法。
最简单的是最后一个。或者前两个与最后一个的组合。通过您喜欢的方法(AJAX 日历、jQuery 日历、或任何您喜欢的方法)添加日历控件,并将其填充到文本字段中。然后运行一些 JavaScript 来更改 URL 查询字符串,这将重新加载页面。
转到 Kentico 转发器的 Web 部件属性。在
内容过滤器->WHERE条件
字段中,您可以编写标准SQL WHERE子句并通过特殊宏注入查询字符串参数:{?QUERYSTRINGPARAMETERNAME?}
。例如 http://url/page?myfilter=2 将是{?myfilter?}
。这将使WHERE
子句类似于:{?myfilter?} = '' OR {?myfilter?} = SqlFieldToCompare
。Kentico 声称他们为了安全而逃避了该宏,尽管我个人还没有证实这一点。不过对我们有用。
如果您使用客户用户控件或 Web 部件,则可以使用带有 Control 宏(而不是上面的 QueryString 宏)的更安全的回发方法。
有关宏的详细信息,请参阅开发人员指南附录 A 宏。
There are several ways.
The easiest would be the last one. Or a combination of the first two with the last one. Add your calendar control via your preferred method (an AJAX Calendar, jQuery calendar, <asp:Calendar>, or whatever you like) and have it populate in a text field. Then have that run some JavaScript to change the URL query string which will reload the page.
Go to your Kentico repeater's web part properties. In the
Content filter->WHERE condition
field, you can write a standard SQL WHERE clause and inject query string parameters via the special macro:{?QUERYSTRINGPARAMETERNAME?}
. For example http://url/page?myfilter=2 would be{?myfilter?}
. That would make theWHERE
clause something like:{?myfilter?} = '' OR {?myfilter?} = SqlFieldToCompare
.Kentico claims they escape that macro for security, though I haven't personally confirmed that. Works for us though.
If you went with a customer user control or web part, you could use safer postback methods with a Control macro (instead of the above QueryString macro).
For more info on macros, see the Developer's Guide Appendix A Macros.