Multiple index in search result transformation is not working with Kentico - search

I have two different kinds of indexes both are working fine at least in the search preview of my local index.
I added both of them to my smart search part in indexes area, one is a page crawler and the second is a custom index that searches in the media library.
The issue is that the results just match with the results of the crawler and are not showing anything of the custom index.
I think the problem is my smartSearchResults transformation because each time that I try to add a field from the custom index I'm getting an error that the value does not exist.
my question is how to use both indexes to retrieve all the results in the same web part?
this is how looks the trasformation
<div class="result">
<!-- Search result title -->
<div>
<a href='<%# SearchResultUrl() %>'>
<%#SearchHighlight(HTMLHelper.HTMLEncode(CMS.Base.Web.UI.ControlsHelper.RemoveDynamicControls(DataHelper.GetNotEmpty(Eval("Title"), "/"))), "<span style='font-weight:bold;'>", "</span>")%>
</a>
</div>
<p class="content">
<%#
IfCompare(GetSearchValue("UseCustomContent"), true,
SearchHighlight(LimitLength(HTMLHelper.StripTags(Eval<string>("Content")), 280), "<strong>", "</strong>"),
SearchHighlight(LimitLength(HTMLHelper.StripTags(GetSearchValue("CustomContent").ToString()), 280), "<strong>", "</strong>")
)
%>
</p><!-- content -->
<%-- MEDIA LIBRARY CONTENT--%>
<div>
<%#GetSearchValue("FileName") %>
</div>
<div class="file">
<i class="<%# GetFileIconClass(Eval<string>("documentExtensions")) %>"></i>
</div><!-- file -->
</div>
</div>
But I'm getting no results message

When getting specific field values from a search index you cannot use the simple Eval("ColumnName"). You have to use another method, GetSearchValue("ColumnName"). The Eval() method works mainly with the following columns Title, Content, Image. If you're already using the GetSearchValue() method then you need to update your question to reflect what you're using or have already tried.

You will have to check if the value exists before you try to use it. You can use IfEmpty for this. An Example:
<%# IfEmpty(GetSearchValue("Email"),"","<span class='label'>Email</span>")%>
<%# IfEmpty(GetSearchValue("Email"),"",GetSearchValue("Email"))%>

Related

How to get href attribute using selenium for python?

I want to get the href attributes from the given HTML code so that i can go inside the link and scrape some data from it.
<div class="cb-col cb-col-67 cb-rank-plyr"> <a class="text-hvr-underline text-bold cb-font-16" href="/profiles/1643/aaron-finch" title="Aaron Finch's Profile">Aaron Finch</a> <div class="cb-font-12 text-gray">AUSTRALIA</div> </div>
<div class="cb-col cb-col-67 cb-rank-plyr"> <a class="text-hvr-underline text-bold cb-font-16" href="/profiles/10863/fakhar-zaman" title="Fakhar Zaman's Profile">Fakhar Zaman</a> <div class="cb-font-12 text-gray">PAKISTAN</div> </div>
I want to get the attributes of href and save it to a list.
You can use regular expressions to parse out thinks in the HTML such as that href tag.
Here is an article explaining that: https://medium.com/#tracy_blog/regex-and-selenium-2c5a89f23a17
To accomplish this, I would consider using get_attribute(name) over a regular expression.

Getting the value of page type form

I'm trying to add a new field named "AlternateLink" to our news page types.
Currently the "Read More" button goes to the full article page with the following:
Read More
I've updated it to:
Read More
but even with a link in the Alternate Link field (see attached image), it always links to the full article page instead of the alternate link.
I tried the same IfEmpty statement with other existing field names such as "NewsTitle" or "NewsImage" and those seem to work so the issue seems to be "AlternateLink" field name.
I created a field with the ID of "AlternateLink" as a text box. Am I missing another step to make it capture the value?
EDIT: AlternateLink is the only new thing I'm adding. All of the existing values (NewsTeaser, NewsTitle, NewsSummary, etc.) all work. Full code:
<div class="blog-post col-md-12 clearfix">
<cms:Media ID="mTeaser" runat="server" Url='<%# Eval("NewsTeaser") %>' Class="img-responsive" />
<h2 class="blog-title"><%# Eval("NewsTitle",true) %></h2>
<div class="post-info">
<i class="fa fa-clock-o"></i><%# GetDateTime("NewsReleaseDate", "MMMM dd, yyyy") %>
</div>
<p><%# Eval("NewsSummary") %></p>
Read More
<span class="hr col-md-12 col-sm-12 col-xs-12"></span>
</div>
You don't need Eval for Text/XML transformations.
Have you checked columns field of the web part, that shows news on the page? Make sure AlternateLink column is also listed there.
Have you tested using just <%#Eval("AlternateLink",true)%> to see what it returns?
Looks like your code is {%Eval("AlternateLink",true)%} when it should be {%AlternateLink%}. <%#%> is for ASPX Transformations. {%%} is for Text/XML transformations, which it looks like you are using.
Could you please try this.
Read More

how to make custom templates in Koken

I'm using Koken and would like to customize the template for text entries by putting the date at the top of the entry.
I hacked a call to new Date() into the core template file /admin/templates/text.tmpl.html
<div id="entry-editor">
<div id="edit-area" data-bind="html: content() ||
'<p class=\'date\'>' + new Date() + '</p>
<p class=\'media-row\'><br /></p>'">
</div>
</div> <!-- close #entry-editor -->
This works fine, but I know the perils of hacking core files.
As of this writing, I don't see an answer on the page linked as "define your own custom template types" on help.koken.me.
Without hacking core files, how can I have Koken add a date to the top of each text entry?
From http://help.koken.me/customer/portal/questions/1080677-how-to-make-custom-templates-in-koken-
Simply place a <koken:time> tag in the customized theme template.
For example, in my /storage/themes/<custom-theme-name>/essay.lens file:
<header>
<h2>
<koken:link>{{ essay.title }}</koken:link>
</h2>
<p>
<strong><koken:time show="time" /> <koken:time show="date" /></strong>
</p>
</header>

Content rating control is always hidden

I've added the following code to the selected transformation of a News List webpart:
<%# Register Src="~/CMSAdminControls/ContentRating/RatingControl.ascx" TagName="RatingControl" TagPrefix="cms" %>
<cms:RatingControl ID="elemRating" runat="server" Enabled="true" RatingType="Stars" ExternalValue='
<%# Convert.ToString(CMS.GlobalHelper.ValidationHelper.GetDouble(Eval("DocumentRatingValue"), 0)/((CMS.GlobalHelper.ValidationHelper.GetDouble(Eval("DocumentRatings"), 0) == 0?1:CMS.GlobalHelper.ValidationHelper.GetDouble(Eval("DocumentRatings"), 1)))) %>' />
The rest of the selected transformation is the same as the default.
According to the Kentico documentation this should add the webpart to the details page of a news item.
For some reason the input tag is getting rendered as follows:
<input type="hidden" name="p$lt$zoneContent$pageplaceholder$pageplaceholder$lt$News$NewsList$repItems$ctl00$ctl00$elemRating$RatingControl$elemRating_RatingExtender_ClientState" id="p_lt_zoneContent_pageplaceholder_pageplaceholder_lt_News_NewsList_repItems_ctl00_ctl00_elemRating_RatingControl_elemRating_RatingExtender_ClientState" value="0">
note the type="hidden" attribute. This causes the control not to render and I'm not sure where to fix this.
As mentioned in my comment. The is actually just used to store the value. Below that, it renders some extra content that will not display unless some CSS classes are carried over from the CMSDesk.css.
You can either copy the necessary CSS classes into your own CSS, or just import the CMSDesk.css file where necessary to make sure the rating elements are displaying.

Why isn't my list displaying in Orchard?

In Orchard 1.3.10 when I create a list it gets assigned a permalink such as /people. When I add a person to the list and go to /people the person does not display. I see
When I add a widget to display people the person displays.
Am I doing something wrong, or is this Orchard working as designed?
Using the shape tracing module I see this In my content zone:
<div class="zone zone-content"> <div class="content-control">
<div class="manage-actions">Edit</div>
<article class="content-item list">
<header>
</header>
</article>
</div>
</div>
Creating a new site fixed my issue.
On my debug site I'm able to work around the issue by changing my list sort order, but not on my real site.
I filed a bug here: http://orchard.codeplex.com/workitem/18421

Resources