Chameleon Filterby PostID - howto?

This post has 8 Replies | 2 Followers

Top 75 Contributor
Posts 295
Points 2,765
Anders V. Posted: Wed, Feb 21 2007 11:22 AM

Hi, I give up Smile  Having failed to get the subjectline of post with PostID 8 outputed on the frontpage:

Attempt 1:

     <CSControl:PostData  Text="|{0}|" Property="Body" runat="server">
        <DisplayConditions>
            <CSControl:PostPropertyValueComparison ComparisonProperty="PostID" ComparisonValue="8" Operator="EqualTo" runat="server" />
        </DisplayConditions>
    </CSControl:PostData>

Attempt 2:

    <CSControl:PostData DataSource="<%# WeblogPosts.GetPost(8, false, true,true) %>" Text="Subject:{0}" Property="Subject" runat="server">
    </CSControl:PostData>

Attempt 3:

     <CSBlog:WeblogPostData DataSource="<%# WeblogPosts.GetPost(8, false, true,true) %>" runat="server">
        <ContentTemplate>
            <%# Eval("Subject") %>
        </ContentTemplate>
    </CSBlog:WeblogPostData>

 I also thought of using a PostList but.. will wait for your reply now Smile

Thanks,
Anders

  • | Post Points: 20
Top 10 Contributor
Posts 3,424
Points 65,565
CS Developers
Ben Tiedt replied on Wed, Feb 21 2007 11:49 PM

This is a somewhat unusual case (using a specific ID), but you can use an application-specific post list, such as:

<CSBlog:WeblogPostList runat="server">
   <QueryOverrides PostID="499227" />
   <ItemTemplate>
      <CSBlog:WeblogPostData Property="Subject" runat="server" />
   </ItemTemplate>
</CSBlog:WeblogPostList>

Ben Tiedt's Blog

  • | Post Points: 20
Top 75 Contributor
Posts 295
Points 2,765
Anders V. replied on Thu, Feb 22 2007 4:21 AM
Hi Ben, thanks that did the trick. I have discovered that the blog (containing the post) is required to be "Included in Community aggregate". Is there a way to retrieve the post without having the blog set to community aggregate?

I found that setting the particular blog to the default weblog in cs.config I am able to retrieve the post - however this is a half solution.

Thanks;
Anders
  • | Post Points: 5
Top 75 Contributor
Posts 295
Points 2,765
Anders V. replied on Thu, Feb 22 2007 6:19 AM

I found a solution. We wanted to retrieve a blogpage/article. This is how you do it:

    <CSBlog:WeblogPostList runat="server">
        <QueryOverrides PostID="6" BlogPostType="Article" PostConfig="Empty" />
        <ItemTemplate>
            <CSBlog:WeblogPostData Property="Subject" Tag="h2" runat="server" />
        </ItemTemplate>
    </CSBlog:WeblogPostList>

The tricky part was setting PostConfig to the correct value  Smile
With this solution we dont need to set the defaultApplicationKey value in cs.config.

This is amazing stuff - great work on the Chameleon guys!
Anders

  • | Post Points: 20
Top 10 Contributor
Posts 3,424
Points 65,565
CS Developers
Ben Tiedt replied on Thu, Feb 22 2007 8:34 AM

Excellent.  Glad you're enjoying Chameleon. Smile

Most of the CS API is exposed via Chameleon controls.

Ben Tiedt's Blog

  • | Post Points: 20
Top 75 Contributor
Posts 295
Points 2,765
Anders V. replied on Thu, Feb 22 2007 9:12 AM
A related question to the WeblogPostList: I am outputting the Body text of the articlepost. However, all formatting is removed. Even if I use FormattedBody:

<CSBlog:WeblogPostData Property="FormattedBody" TruncateAt="120" TruncationEllipsisText="..." runat="server" />


Using Eval("Body") keeps formatting but then we lose the neat TruncateAt feature.

Thanks,
Anders
  • | Post Points: 35
Top 25 Contributor
Posts 2,243
Points 44,805
CS Developers

Correct. TruncateAt will remove all formatting before truncating the post.

You can not safely truncate a post written in HTML without first removing the HTML. Otherwise you run the risk of generating invalid markup and making the page unusable.

HTH,
Scott

  • | Post Points: 5
Top 10 Contributor
Posts 3,424
Points 65,565
CS Developers
Ben Tiedt replied on Thu, Feb 22 2007 9:19 AM

Anders V.:
A related question to the WeblogPostList: I am outputting the Body text of the articlepost. However, all formatting is removed. Even if I use FormattedBody:

<CSBlog:WeblogPostData Property="FormattedBody" TruncateAt="120" TruncationEllipsisText="..." runat="server" />

Using Eval("Body") keeps formatting but then we lose the neat TruncateAt feature.

Using TruncateAt will cause the HTML to be stripped -- this results in a HTML-safe truncated version of the page (without unclosed tags or improperly early-closed tags).  Accessing just Property="Body" or Property="FormattedBody" (without specifying a value for TruncateAt) will include all formatting.

Note, too, that you should not render Eval("Body") -- this property contains the original, unprocessed text before CSModules (censorship, html scrubbing, etc) have been executed.  Accessing the Body or FormattedBody properties of the WeblogPostData control will ensure that you are rendering the content with all CSModules executed.

Ben Tiedt's Blog

  • | Post Points: 20
Top 75 Contributor
Posts 295
Points 2,765
Anders V. replied on Thu, Feb 22 2007 9:33 AM
That makes sense. Thanks Ben.
  • | Post Points: 5
Page 1 of 1 (9 items) | RSS
Powered by Community Server (Commercial Edition), by Telligent Systems

Copyright© 2008 Telligent Systems Inc. All rights reserved
CommunityServer.com  •  Telligent.com