ASPX templates
Version 5.x > ASPX templates > Tag clouds, set where clause on repeater View modes: 
User avatar
Certified Developer v7
Certified  Developer v7
adam-syndicut - 1/28/2011 5:02:27 AM
   
Tag clouds, set where clause on repeater
i'm having trouble setting the where clause on the repeater that displays the docuemnts associated to the click tag in the tag cloud web part

here is my code

 <cms:CMSUpdatePanel runat="server" ID="UpdatePanel1">
<ContentTemplate>
<cms:CMSRepeater ID="AllPosts" runat="server" OnItemDataBound="AllPosts_ItemDataBound" DelayedLoading="true" ClassNames="cms.blogpost" OrderBy="BlogPostDate DESC" TransformationName="cms.blog.PostPreview" SelectedItemTransformationName="cms.blogpost.Default" EnableViewState="false" WhereCondition="({%tagid|(toint)%} = 0 AND '{%tagname%}'='') OR (DocumentID IN (SELECT DocumentID FROM CMS_DocumentTag WHERE TagID = {%tagid|(toint)%}))OR (DocumentID IN (SELECT DocumentID FROM CMS_DocumentTag WHERE TagID IN (SELECT TagID FROM CMS_Tag WHERE TagName = '{%tagname%}' AND TagGroupID = {%groupid|(toint)%})))"></cms:CMSRepeater>
<cc1:UniPager ID="UniPager" PageControl="AllPosts" runat="server" PageSize="10" PagerMode="PostBack" DisplayPreviousNextAutomatically="false" DisplayFirstLastAutomatically="false" HidePagerForSinglePage="true">
<NextPageTemplate>
<li><a href="<%# Eval("NextURL") %>">Next</a></li>
</NextPageTemplate>
<PageNumbersTemplate>
<li><a href="<%# Eval("PageURL") %>"><%# Eval("Page") %></a></li>
</PageNumbersTemplate>
<PreviousPageTemplate>
<li><a href="<%# Eval("PreviousURL") %>">Previous</a></li>
</PreviousPageTemplate>
<LayoutTemplate>
<div class="pager">
<ul>
<asp:PlaceHolder runat="server" ID="plcPreviousPage"></asp:PlaceHolder>
<asp:PlaceHolder runat="server" ID="plcPageNumbers"></asp:PlaceHolder>
<asp:PlaceHolder runat="server" ID="plcNextPage"></asp:PlaceHolder>
</ul>
</div>
</LayoutTemplate>
</cc1:UniPager>
</ContentTemplate>
</cms:CMSUpdatePanel>
<uc1:CommentView runat="server" ID="CommentView" ShowForDocumentTypes="cms.blogpost" CheckPermissions="False" AbuseReportAccess="Nobody" ShowDeleteButton="true" ShowEditButton="true" DisplayTrackbacks="true" EnableViewState="false" />
</div>
<div id="right-content">
<uc1:TagCloud ID="TagCloud" runat="server" SiteName="Quiller" ShowForDocumentTypes="cms.blog;cms.menuitem" TagGroupName="Blog" QueryStringName="tagid" />
</div>


i'm getting this error on the where clause

[DataConnection.ExecuteQuery]: Query: SELECT  * FROM View_CONTENT_BlogPost_Joined WHERE (((((SiteName = N'Quiller') AND (Published = 1)) AND (DocumentCulture = N'en-GB')) AND (NodeAliasPath LIKE N'/Memorandum/%')) AND (({%tagid|(toint)%} = 0 AND '{%tagname%}'='') OR (DocumentID IN (SELECT DocumentID FROM CMS_DocumentTag WHERE TagID = {%tagid|(toint)%}))OR (DocumentID IN (SELECT DocumentID FROM CMS_DocumentTag WHERE TagID IN (SELECT TagID FROM CMS_Tag WHERE TagName = '{%tagname%}' AND TagGroupID = {%groupid|(toint)%}))))) ORDER BY BlogPostDate DESC : caused exception: Incorrect syntax near '?'.
Incorrect syntax near '?'.
Incorrect syntax near '?'.


any ideas

User avatar
Kentico Developer
Kentico Developer
kentico_ondrejv - 2/7/2011 10:08:21 AM
   
RE:Tag clouds, set where clause on repeater
Hello,

As you can see in the error message - query string macros are not resolved when they are put to the Repeater's property directly. Please fill the Where condition in the code-behind like this:

// Get ID of the currently requested tag
string tagId = QueryHelper.GetString("tagid", string.Empty).Replace("'", "''");

this.RandomProducts.ReloadData();
// Get all the documents with specified tag applied
string where = "'" + tagId + "' = '' OR (DocumentID IN ( SELECT DocumentID FROM CMS_DocumentTag WHERE TagID = '" + tagId + "'))";

// Get all articles document according specified WHERE condition
this.AllPosts.WhereCondition = where;
this.AllPosts.ReloadData(true);


If you want your tag cloud Repeater to work with Tag Name as well, please adjust the Where condition accordingly.

Best regards
Ondrej Vasil

User avatar
Certified Developer v7
Certified  Developer v7
adam-syndicut - 2/8/2011 6:40:14 AM
   
RE:Tag clouds, set where clause on repeater
cheers that works perfect now.

how do i get back to the main blog page when using the tag clouds on a details page with the comment box

e.g i am on

http://adam-dev4.internal.com:8005/blog.aspx

i click a tag in the cloud which then displays just the posts with "tagid 1"

http://adam-dev4.internal.com:8005/blog.aspx?tagid=1

but if i'm on

http://adam-dev4.syndicut.com:8005/blog/November-2010/Aliquam-sodales.aspx

and i click click a tag in the cloud which as previous it stays on that details page but i want it to go back to the main blog page. is there a setting on the webpart for this

User avatar
Certified Developer v7
Certified  Developer v7
adam-syndicut - 2/8/2011 6:55:02 AM
   
RE:Tag clouds, set where clause on repeater
documentlisturl !

should have looked a bit hard myself