.net Kentico:如何从搜索转换内部访问搜索字符串?
如何从搜索转换内部访问搜索字符串?在文档或论坛中找不到它。尝试了.net Kentico:如何从搜索转换内部访问搜索字符串?,.net,content-management-system,kentico,.net,Content Management System,Kentico,如何从搜索转换内部访问搜索字符串?在文档或论坛中找不到它。尝试了,但它当然不存在 任何帮助都将不胜感激。谢谢。搜索字符串通常在querystring中可用,因此您可以像 在您的案例“searchtext”中,querystring(可能)位于何处 如果您需要更复杂的搜索转换,您可以在公司网站上的示例中启发自己: <div style="margin-bottom: 30px;"> <%-- Search result image --%> <div styl
,但它当然不存在
任何帮助都将不胜感激。谢谢。搜索字符串通常在querystring中可用,因此您可以像 在您的案例“searchtext”中,querystring(可能)位于何处 如果您需要更复杂的搜索转换,您可以在公司网站上的示例中启发自己:
<div style="margin-bottom: 30px;">
<%-- Search result image --%>
<div style="float: left; border: solid 1px #eeeeee; height:90px; width:90px; margin-right: 5px;text-align:center;">
<img src="<%# GetSearchImageUrl("/CMSModules/CMS_SmartSearch/no_image.gif",90) %>" alt="" />
</div>
<div style="margin-left: 108px;">
<%-- Search result title --%>
<div>
<a style="font-weight: bold" href='<%# SearchResultUrl(true) %>'>
<%#SearchHighlight(HTMLHelper.HTMLEncode(CMS.Base.Web.UI.ControlsHelper.RemoveDynamicControls(DataHelper.GetNotEmpty(Eval("Title"), "/"))), "<span style='font-weight:bold;'>", "</span>")%>
</a>
</div>
<%-- Search result content --%>
<div style="margin-top: 5px; min-height:40px">
<%#SearchHighlight(HTMLHelper.HTMLEncode(TextHelper.LimitLength(HttpUtility.HtmlDecode(HTMLHelper.StripTags(CMS.Base.Web.UI.ControlsHelper.RemoveDynamicControls(GetSearchedContent(DataHelper.GetNotEmpty(Eval("Content"), ""))), false, " ")), 280, "...")), "<span style='background-color: #FEFF8F'>", "</span>")%><br />
</div>
<%-- Relevance, URL, Creattion --%>
<div style="margin-top: 5px;">
<%-- Relevance --%>
<div title="Relevance: <%# Convert.ToInt32(ValidationHelper.GetDouble(Eval("Score"), 0) * 100) %>%"
style="width: 50px; border: solid 1px #aaaaaa; margin-top: 7px; margin-right: 6px;
float: left; color: #0000ff; font-size: 2pt; line-height: 4px; height: 4px;">
<div style="<%# "background-color:#a7d3a7;width:" + Convert.ToString(Convert.ToInt32(ValidationHelper.GetDouble(Eval("Score"), 0) * 50)) + "px;height:4px;line-height: 4px;"%>">
</div>
</div>
<%-- URL --%>
<span style="color: #008000">
<%# TextHelper.BreakLine(SearchHighlight(SearchResultUrl(true),"<strong>","</strong>"),100,"<br />") %>
</span>
<%-- Creation --%>
<span style="padding-left:5px;;color: #888888; font-size: 9pt">
(<%# GetDateTimeString(ValidationHelper.GetDateTime(Eval("Created"), DateTimeHelper.ZERO_TIME), true) %>)
</span>
</div>
</div>
<div style="clear: both">
</div>
</div>
“alt=”“/>
()
搜索字符串通常在querystring中可用,因此您可以像
在您的案例“searchtext”中,querystring(可能)位于何处
如果您需要更复杂的搜索转换,您可以在公司网站上的示例中启发自己:
<div style="margin-bottom: 30px;">
<%-- Search result image --%>
<div style="float: left; border: solid 1px #eeeeee; height:90px; width:90px; margin-right: 5px;text-align:center;">
<img src="<%# GetSearchImageUrl("/CMSModules/CMS_SmartSearch/no_image.gif",90) %>" alt="" />
</div>
<div style="margin-left: 108px;">
<%-- Search result title --%>
<div>
<a style="font-weight: bold" href='<%# SearchResultUrl(true) %>'>
<%#SearchHighlight(HTMLHelper.HTMLEncode(CMS.Base.Web.UI.ControlsHelper.RemoveDynamicControls(DataHelper.GetNotEmpty(Eval("Title"), "/"))), "<span style='font-weight:bold;'>", "</span>")%>
</a>
</div>
<%-- Search result content --%>
<div style="margin-top: 5px; min-height:40px">
<%#SearchHighlight(HTMLHelper.HTMLEncode(TextHelper.LimitLength(HttpUtility.HtmlDecode(HTMLHelper.StripTags(CMS.Base.Web.UI.ControlsHelper.RemoveDynamicControls(GetSearchedContent(DataHelper.GetNotEmpty(Eval("Content"), ""))), false, " ")), 280, "...")), "<span style='background-color: #FEFF8F'>", "</span>")%><br />
</div>
<%-- Relevance, URL, Creattion --%>
<div style="margin-top: 5px;">
<%-- Relevance --%>
<div title="Relevance: <%# Convert.ToInt32(ValidationHelper.GetDouble(Eval("Score"), 0) * 100) %>%"
style="width: 50px; border: solid 1px #aaaaaa; margin-top: 7px; margin-right: 6px;
float: left; color: #0000ff; font-size: 2pt; line-height: 4px; height: 4px;">
<div style="<%# "background-color:#a7d3a7;width:" + Convert.ToString(Convert.ToInt32(ValidationHelper.GetDouble(Eval("Score"), 0) * 50)) + "px;height:4px;line-height: 4px;"%>">
</div>
</div>
<%-- URL --%>
<span style="color: #008000">
<%# TextHelper.BreakLine(SearchHighlight(SearchResultUrl(true),"<strong>","</strong>"),100,"<br />") %>
</span>
<%-- Creation --%>
<span style="padding-left:5px;;color: #888888; font-size: 9pt">
(<%# GetDateTimeString(ValidationHelper.GetDateTime(Eval("Created"), DateTimeHelper.ZERO_TIME), true) %>)
</span>
</div>
</div>
<div style="clear: both">
</div>
</div>
“alt=”“/>
()
感谢您指出了正确的方向。在ASCX转换中,Request.QueryString[“searchtext”]
对我很有效。但是请注意,您使用“稀有”QueryString(传递到sql查询,在html输出中呈现…)的操作是否正确。Kentico推荐的对查询字符串/用户输入进行消毒的方法是什么???是否有任何内置方法可以执行相同的操作?这将非常取决于您的CMS版本,但该方法是CMS.DataEngine.SqlHelper.GetSafeQueryString(“我的字符串”)。这取决于您希望使用什么querystring forHanks指向正确的方向。在ASCX转换中,Request.QueryString[“searchtext”]
对我很有效。但是请注意,您使用“稀有”QueryString(传递到sql查询,在html输出中呈现…)的操作是否正确。Kentico推荐的对查询字符串/用户输入进行消毒的方法是什么???是否有任何内置方法可以执行相同的操作?这将非常取决于您的CMS版本,但方法是CMS.DataEngine.SqlHelper.GetSafeQueryString(“我的字符串”),这取决于您希望使用querystring做什么