Include new line character in value attribute of Liferay search container - liferay

I have the following line of code of search container.
I want to include a new line between the two values that I want to display..
<liferay-ui:search-container-column-text name='Employee Name'
value='<%=String.valueOf(search.getEmpFname()) + String.valueOf(search.getEmpLname()) +"\n" + String.valueOf(search.getEmpTitle()) %>'
href="" >
The reason I want it this way is that I want all these values in one box each row.
So how should I format the above code so that I have:
String.valueOf(search.getEmpFname()) + String.valueOf(search.getEmpLname())
on one line and
String.valueOf(search.getEmpTitle())
on the next line of the same row.

Converting my comment as an answer:
You can try using <br> tag instead of "\n" like this:
String.valueOf(search.getEmpLname()) + "<br>" + String.valueOf(search.getEmpTitle()`
or you can use <liferay-ui:search-container-column-jsp tag instead of <liferay-ui:search-container-column-text tag
or else use the tag as following:
<liferay-ui:search-container-column-text name='Employee Name' href="">
<%=String.valueOf(search.getEmpFname()) + String.valueOf(search.getEmpLname()) %>
<br>
<%= String.valueOf(search.getEmpTitle()) %>
</liferay-ui:search-container-column-text>*emphasized text**emphasized text*

Related

Split EJS text including template in the middle

I have a long text inside a variable that is rendered through EJS:
<% var longText = 'Very long text' %>
<%- longText %>
So far, so good; works fine. The thing is that I want to split this long text in two parts and have another EJS template inserted between these parts.
How to do that?
Got it.
text.split("<br /><br />")
// <br /><br /> is the paragraph marker
It returns me an array with the paragraphs of my text.
I then insert each element of the array (each paragraph) wherever I want, with whichever I want beteen elements.

kentico ascx transformation, every nth

Here's my transformation:
<%# IsFirst() ? "<div class='row'>" : "" %>
<div class='col-xs-12 col-md-3 col-bdlt'>
<div class='bdlt lt'>
<asp:PlaceHolder runat="server" Visible='<%# IfEmpty( Eval("Headshot"), false, true ) %>'>
<img src="<%# Eval("Headshot") %>" alt="<%# Eval("Name") %>" class='img-responsive'>
</asp:PlaceHolder>
<p class='name'><%# Eval("Name") %><%# IfEmpty( Eval("Accolades"),"</p>",",</p> <p class='accolades'>" + Eval("Accolades") + "</p>" ) %>
<p><%# Eval("Copy") %></p>
</div>
</div>
<%# IsLast() ? "</div>" : "" %>
I'm running Bootstrap, so i'm wrapping these elements in a row. Things are working, but depending on the amount of copy, it's not looking as it should. What i'd like do is have a row for each group of 4.
So like this
Row
item
item
item
item
Row
item
etc.
So after every 4th, close the row div, and start a new one. I think my first line is good, it's the last where i think the logic is needed.
To start the row, you want to make sure the first record starts a row:
<%# ( (DataItemIndex % 4 == 0) ? "<div class=\"row\">" : "" ) %> <!-- Start Row -->
To close the row, you want to make sure the last record ends the current row.
<%# (DataItemIndex % 4 == 3 || DataItemIndex == DataRowView.DataView.Count - 1 ? "</div>" : "") %> <!-- Close Row -->
You want to utilize the DataItemIndex value, and do something like this, coupled with the Modulo
You compare the DataItemIndex %4 = 3 because DataItemIndex is 0 based, so the 4th, 8th, 12th rows have index of 3, 7, 11 which modulo 4 are all 3.

Kentico Trim in a transformation with Eval

I'm trying to trim ending white space from AlertTitle in an ascx transforamtion. I know there is TrimEnd, but i'm drawing a blank getting it to work.
The V9 Documentation has a method for this(https://docs.kentico.com/display/K9/Adding+custom+methods+to+transformations) but i don't want to fix the length.
Here's the transformatin code snippet.
<asp:placeholder id="alert" runat="server" Visible="false">
<li data-date="<%# Eval("AlertDate") %>">
<p class="alert-date"><%# FormatDateTime(Eval("AlertDate"), "MMMM dd, yyyy") %> </p>
<p class="alert-copy"><%# Eval("AlertTitle") %> <%# IfEmpty(Eval("AlertCopy"),"", "... <a href='" + GetDocumentUrl() + "'>" + CMS.Helpers.ResHelper.GetString("kff.Generic-ReadMore") + "</a> &raquo") %></p>
</li>
</asp:placeholder>
In addition to using Trim() or TrimEnd() in the transformation, you can also set it up so Kentico will automatically trim the fields when the form is submitted by checking the "Trim" checkbox under "advanced" Editing control settings.
Like so:
You probably need to cast the ouput of Eval to a string first:
<%# ((string)Eval("AlertTitle")).TrimEnd() %>
In v8 and newer, you can also use a different version of Felix's answer
<%# Eval<string>("AlertTitle").TrimEnd() %>

Liferay Portal 6.2 - checkbox into search container

I created a search container table that contains a column checkbox type, i.e.
<liferay-ui:search-container-column-text
name="territoriale"
orderable="<%= true %>"
>
<input type="checkbox" id="territoriale" checked="<%= cmt.getTerritoriale() == 1 %>" />
</liferay-ui:search-container-column-text>
This table is declared inside a jsp included using liferay-util:include, but can also be refreshed in the next steps by click on search button.
What happen is that when the table appears for the first time, I see that column just with text (value is "1"), when I click search button that runs the ajax call, the resource action return the correct checkbox in column.
Any ideas?
Below some screen shot
Thanks
Column after page load
Column after click on search button
This works fine on 6.2 CE ga5:
<liferay-ui:search-container-column-text
name="checkbox"
orderable="<%= true %>"
>
<% String checked = (Math.random() < 0.5) ? "checked" : ""; %>
<input type="checkbox" <%= checked %>/>
</liferay-ui:search-container-column-text>
So the root cause of your issue should be somewhere else. You may output cmt.getTerritoriale() into html to check its content.
I think, that checked="<%= cmt.getTerritoriale() == 1 %>" is not correct,
you may use checked or nothing.
See here about using checked attribute.
You can also use rowchecker as was mentioned in the comments of Pankajkumar Kathiriya.

How does VIM's Ultisnips plugin handle delete inside of HTML snips? How do I change id to class in a div?

I'm new to Ultisnips. In insert mode I type div [tab] then I get:
<div id="name">
</div>
With the cursor on name. If i wan't to use class instead of id I hit backspace and get this
<div>
</div>
With the cursor on the first v. Now if I want to start typing 'class' I end up with this
<diclassv>
</div>
If I delete class and hit [esc] l i 'class' I end up with this
<div id=" "class>
</div>
What's going on here? What am I doing wrong?
I want
<div class="foo">
</div>
I'm not finding a way to do what you're looking for either, at least with the
standard snippet definitions.
I've created an improved snippet for that which you can start using by placing
the following in ~/.vim/UltiSnips/html.snippets (my version of that file is available from
GitHub):
clearsnippets div
snippet div "XHTML <div>"
<div`!p snip.rv=' id="' if t[1] else ""`${1:name}`!p snip.rv = '"' if t[1] else ""``!p snip.rv=' class="' if t[2] else ""`${2:name}`!p snip.rv = '"' if t[2] else ""`>
$0
</div>
endsnippet
This will provide both id and class attributes by default, eliminating the
one(s) where the value is deleted.
The official version of UltiSnips on GitHub now includes this version of the snippet.

Resources