Article tags to foreach

Zbyněk Nedoma asked on August 2, 2018 12:27

Hi, can you please help me how to do do this transformation in ASCX? I am creating transformation for Article Repeater and I need to get the tags of that article. I saw some answers here, but they are not working https://devnet.kentico.com/questions/foreach-loop-in-transformation

I was trying to do it like this:

<% foreach (var tagName in GetSearchValue("DocumentTags").Split(",")) { %>
    <li><a href="your link here"><%= tagName %></a>
<% } %>

It returns Error message [TempITemplate.Template]: http://server/CMSVirtualFiles/Transformations/=vg=25857332-dd58-4094-b8eb-7bc1d4915921/Conseq.Article/ConseqNewsBox.ascx(17): error CS1061: 'object' does not contain a definition for 'Split' and no extension method 'Split' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?)

But it is not working.

Thanks for helping. Zbynek :)

Recent Answers


Anton Grekhovodov answered on August 2, 2018 13:14

Hi,
Split method is extension for strings,so try to do GetSearchValue("DocumentTags).ToString() and then split it.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.