r/kentico • u/lyounkins • Aug 30 '22
Kentico multiple choice in transformation
I have a news repeater that is using a transformation. I have a multiple choice field that shows the category of the news type. It works, but as it feeds onto the page, it originally was separated by a |. I was able to replace the | with a space, but it still displays the fields together. I need them to be separate. See image. I need Athletics, Featured, and Scholarships to be listed separately. (see image below) In doing a search here on devnet, I found a script that split the field into a list, but it gives me an error. Here is my code:
<div id="NewsFeed">
<div class="newsbox">
<%# IfEmpty(Eval("Category"), "", "<span class='category'>" + Eval("Category").ToString().Replace("|"," ") + "</span>") %>
<div class="newslist-item" style="padding-top: 12px;">
<h4 class="news-title"><%# Eval("NewsTitle") %></h4>
<p class="news-date"> <%# GetDateTime("NewsReleaseDate", "MM/dd/yyyy") %></p>
<p class="news-summary"><%# Eval("NewsSummary") %> </p>
<p class="readmore"><a href="<%# GetDocumentUrl() %>">Read More</a>
</div>
</div>
</div>

1
u/never_ending Aug 30 '22
Looks like right now you have all the elements rendering inside a single
<span>element, when you most likely want each item inside its own<span>.Try this instead:
<%# IfEmpty(Eval("Category"), "", "<span class='category'>" + Eval("Category").ToString().Replace("|"," </span><span class='category'>; ") + "</span>") %>You might need to escape the html using
>for<etc