Display html code in browser in liferay search container - liferay

I am using liferay search container to display tables data. In one of the field, I need to display the HTML code as given. My question is How to Display html code in browser. My code is as follows.
<liferay-ui:search-container-column-text property="question" name="Question" />

You could do something like this:
<liferay-ui:search-container-column-text name="Question" >
<div class="question"><%= nameOfTheObjectInCollection.getQuestion() %></div>
</liferay-ui:search-container-column-text>

Related

Multiple index in search result transformation is not working with Kentico

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"))%>

Node.js Getting values from html and using req.body.<name>

I am trying to retrieve multiple values from HTML and make use of it using req.body..
I am able to do this via message: req.body.message
<form id="message-form" class="input-group input-group-lg" style="">
<input type="text" name="message" class="form-control" aria-label="Large" aria-describedby="inputGroup-sizing-sm">
<div class="input-group-prepend">
<button class="btn btn-primary">Send</button>
</div>
</form>
However, I would like to retrieve the values from elements that are not inside the e.g <span id="item" style="font-weight:bold"> </span>
The reason is that when I load the page, it renders these values dynamically (retrieved from database). When I want to do a POST, I would like to make use of these values that have been rendered previously.
Is there a way to do this?
Many thanks.
Forms don't submit data that does not appear inside a form control.
So you can either:
Store the data somewhere in the server (such as in a session) where you can read it back on a subsequent request (watch out for race conditions!) or
Put the data in a form control instead of or as well as in the span. (Possibly using a hidden input).

How to pass input text value as portlet param

I have a portlet page:
<%# taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet" %>
<portlet:defineObjects />
<portlet:resourceURL var="resourceUrl">
<portlet:param name="startDate" value="" />
</portlet:resourceURL>
<input id="startdateexportaging" type="text" />
<a style="font-size: 15px;" href="${resourceUrl}" >URL</a>
How to pass the content of startdateexportaging as portlet param startDate when clicking the link with resourceUrl?
You could use an onclick handler to add the content to the URL as soon the link is clicked. But that would be cumbersome, error prone and not necessary.
Instead you should add your input to a form and define the URL as action parameter:
<aui:form action="<%= resourceUrl.toString() %>" method="get">
<aui:input name="startDate" type="text" />
<aui:button value="Download" type="submit" />
</aui:form>
(if you don't use AUI - you can use simple HTML tags as well)
Another advantage of this solution: A button instead of a link makes it easier for the user to understand that the content from the text field is submitted. Compare it with the use of links and buttons here on SO - if you enter some information you have to hit a button.
And it is easier for search engines to parse the website, as those try to follow links - but ignore buttons.

Search container column jsp not working in liferay

The Search Container column jsp is not working in liferay.
I am trying to include a jsp within Liferay Search-container of type Document, for displaying search results for a given string.
Below is the snippet of code displaying search-container in the page:
<liferay-ui:search-container searchContainer="<%=tagsearchContainer%>">
<liferay-ui:search-container-results>
results="<%= hits.toList() %>"
total="<%= hits.getLength() %>"
</liferay-ui:search-container-results>
<liferay-ui:search-container-row
className="com.liferay.portal.kernel.search.Document"
escapedModel="<%= false %>"
keyProperty="UID"
modelVar="document"
stringKey="<%=true %>"
>
<liferay-ui:search-container-column-jsp path="/html/search_tag_result_form.jsp"/>
</liferay-ui:search-container-row>
</liferay-ui:search-container>
The search container only displays all fields from the document,all mashed up,without any errors.It does not display the content from the jsp(actually does not include it,and does not throw even if wrong path for jsp is there).Mashed up results are displayed from container-row .
I think you are missing the <liferay-ui:search-iterator /> before the end-tag </liferay-ui:search-container>.
This <liferay-ui:search-iterator /> is used to actually displays the list and the contents inside the <liferay-ui:search-container-row> tag.
Here is a good explanation for most of the commonly used tags for search-container.

how to refer values of one jsp file to other jsp

I am calling jsp on <a href> tag like this
<div align="left"><%=searchList1.getProjid()%></div>
I want to get the value of searchlist1.getProjid in UpdateProject.jsp
How can I do it... please suggest me with example code.
You can send it as parameter:
<div align="left"><%=searchList1.getProjid()%></div>
And then use it in the new jsp like:
request.getParameter('projid');

Resources