Architectural Question

Topics: General, XSLT
May 19, 2011 at 9:36 PM

Hi there.

I am creating a section of my site that will contain blog posts.  I know the Omnicorp example shows how to do most of what I need, however I have one fundamental difference.  I need the posts themselves to be actual pages so they can have nice URLs the way normal pages do, rather than using a query parameter, such as story=(some guid).  

As an example, lets call my page type "Blog Post".  In my XSLT function to show the list of most recent posts, I can use SitemapXml to get a list of sub pages no problem, but how can I filter and sort based on Metadata fields ?  Example, my Blog Post page type will have the meta data fields "Category" and "Post Data", which I'd like to sort and filter on, respectively.  In addition to this question, is there an elegant way to utilize the values of these metadata fields in my xslt template?  Thanks.

Coordinator
May 19, 2011 at 11:00 PM

Quick question - did you take a look at the blog package?

May 20, 2011 at 2:56 PM

i hadn't.  thanks for that, I will take a look and see if this will meet my needs.

May 20, 2011 at 6:27 PM

The blog package should be able to provide you with the technical backend stuff and rendering... to achieve your goal regarding urls you would have to take a look at http://compositec1contrib.codeplex.com/ which provides functionality for better url handling. These discussions are touching the subject 

http://compositec1contrib.codeplex.com/discussions/255920 and http://compositec1.codeplex.com/discussions/256896

May 20, 2011 at 8:04 PM

I looked at the Blog package.  Thanks for that.  Even the way it does the URLs out of the box is fine.  I do have one main question about this before diving in, however --

Is this Package designed as a starting point?  I have some fairly rigid requirements about fields to capture and design -- so will editing the xslt and default Global datatypes the blog uses cause any issues?  For example if I want to change all the fields around for Composite.Community.Blog.Entries (while also changing the Community.Blog.BlogRenderer xslt function), will this break anything?  Another example -- say I wanted someone in the CMS to approve whether or not a Comment is displayed -- Could I add an "Approved" boolean field to Community.Blog.Comments, modify BlogRenderer to only display comments that are approved, and let someone in the CMS manually tick it to true if they want to allow it to appear?

Thanks.

Coordinator
May 20, 2011 at 8:13 PM

You should be able to modify it to your hearts delight - the source code is available at http://c1packages.codeplex.com/

About comments, consider doing it this way: ensure the comment data type has 'publishing workflow'. When people submit a comment, save the comment in the unpublished data scope - this way the comments need to be published before they show up in public.

May 20, 2011 at 8:42 PM

Yea, I'm still kind of new at this.  To be honest I have not really messed with doing any sort of C# code using the platform (which I view as a good thing -- haven't had to, this should be a good opportunity to dive in).  Is the proper way to do this to just download the source of the Blog package, modify SaveComments in CommentsFacade.cs, recompile, dump the new Composite.Community.Blog.dll into my Bin dir?

Coordinator
May 20, 2011 at 9:33 PM
Edited May 20, 2011 at 9:39 PM

Sounds about right - you probably need to replace

DataFacade.AddNew(commentItem);

with

using ( DataConnection dc = new DataConnection( PublicationScope.Unpublished ) )
{
  dc.Add(commentItem);
}

and you should be ready. Note the the original code is using an internal data class, while my code below use the intended public api - our api is fairly new and some packages still call the internal stuff. They do the same, but sorry about the confusion. The new code will store the user comment in the 'unpublished' scope. You should then be able to use the 'publish' feature in the C1 Console to publish the comment.