Where Clause for Tag Names in News List

David Pearson asked on January 30, 2017 21:42

I have a page that contains a list of news with a tag cloud. The Page will show only the related tag when a tag is selected. Using Kentico 8.2

I have the following for a Where Clause where I filter on the TagName in the URL.

DocumentTags like '%{?TagName?}%'

This works with some side effects. Tag Name Maple will return both tags "Some Maple" and Maple instead of just "Maple".

I tried DocumentTags = '%{?TagName?}%'.
This results returns nothing. Is DocumentTags a string with a comma delimited list of tags?

What is a good where clause to filter down to just the word "Maple" when the TagName is Maple?

Thanks David

Recent Answers


Ilesh Mistry answered on January 30, 2017 22:28 (last edited on January 30, 2017 22:34)

Hi David, have you tried '{%tagname%}' without the '%'?

In kentico repeater where clause you could use something similar to

('{%ToInt(tagid, "")%}' = 0 AND '{%tagname%}'='') OR (DocumentID IN (SELECT DocumentID FROM CMS_DocumentTag WHERE TagID = {%ToInt(tagid, "")%} )) OR (DocumentID IN (SELECT DocumentID FROM CMS_DocumentTag WHERE TagID IN (SELECT TagID FROM CMS_Tag WHERE TagName = '{%tagname%}' AND TagGroupID = {%ToInt(groupid, "")%} )))

You can strip out items from it, but hopefully this should help.

1 votesVote for this answer Mark as a Correct answer

Chetan Sharma answered on January 31, 2017 08:42

David, I think Illesh is spot on. The problem is your usage of "%" operator which results in returning results like "Some Mapple" "Apple Mapple" and "Mapple". If you want to return results only for "Mapple" which is an exact match you should consider removing "%" operator.

Thanks, Chetan

0 votesVote for this answer Mark as a Correct answer

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