Question concerning Blog package

Topics: Standard packages
Nov 12, 2010 at 5:03 PM

Hey guys,

On the front page of my site, I would like to have a section that lists the most current blog entries (from my blog page) and when the entry is clicked on, the blog page with the entry clicked is shown. I would think that this wouldn't too difficult to achieve, but my relative newness to XSLT is causing me to draw a blank on that.

I would really appreciate any suggestions on how this could be achieved. (Note: once the News package is updated to 2.0, I will be doing something similar)

Thanks a lot guys!

 

Robert

Coordinator
Nov 12, 2010 at 10:08 PM
Edited Nov 12, 2010 at 10:12 PM

The blog package use an XSLT extension (that come with the blog package) to create the date+title based URL element. So you call this extension to get the info. You can sneak peak in the existing XSLT for BlogRenderer. The primary steps here are:

1) Register the custom XSLT Extension for the blog by adding a call to "Composite.Community.Blog.XsltExtensions" on the Functions tab. Your preview will now display details about this extension

2) Register a namespace to this extension - easiest way is to add the following xmlns declaration inside the <xsl:stylesheet /> element:

xmlns:be="#BlogXsltExtensionsFunction"

3) Make sure that you include the "PageId", "Date" and "Title" fields in the "GetEntriesXml" function call so you have those values in the XML.

4) When you iterate through the resulting <Entries /> elements you go:

                <a href="~/Renderers/Page.aspx{be:GetBlogUrl(@Date, @Title)}?pageId={@PageId}">
                            <xsl:value-of select="@Title" />
                </a>

The markup above is pretty much a raw copy from the BlogRenderer function that ships with the package.

Hope this help :)

Nov 13, 2010 at 12:10 AM

Thank you thank you thank you! :)

 

That was just enough information for me to go forward with. Knowing what to use when and where (like Composite.Community.Blog.XsltExtensions, for instance) is the difficult part. It will just take some time, I guess, poking into areas and learning as I go.

I GREATLY appreciate the assistance and will try to keep these kinds of posts to a minimum. :)

Thanks again!!

Robert

Nov 13, 2010 at 12:31 AM

shouldn't you be able to render the "real" url of your page, and not actually using the Renderers/Page.aspx-pattern which is not very user friendly? What will the markup be for that?

Coordinator
Nov 13, 2010 at 12:59 AM

>> shouldn't you be able to render the "real" url of your page, and not actually using the Renderers/Page.aspx-pattern which is not very user friendly? What will the markup be for that?

C1 automatically replaces url's like ~/Renderers/Page.aspx?id=.... with friendly urls. In "/Renderers/Page.aspx" there's a call to PageUrlHelper.ChangeRenderingPageUrlsToPublic which does this work.

The reason for that is that users friendly url's are subject to change, futher more reference like

 ~/Renderers/Page.aspx?id=....

will be referenced to the same language and publication scope as the page it is put on, f.e. by viewing page in "en-US" all those internal links will shown as links to pages from "en-US" language.

Dec 7, 2010 at 12:33 AM

Ok, I have another question about this.

I have the functionality working except the list of blogs are not being presented in descending chronological order. I cannot really determine what order they are being displayed in.

The BlogRenderer function is displaying in descending order, correctly (of course), however, I cannot see anything in the code that regulates or determines this. 

Any pointers would, again, be most welcome and appreciated.

Thank you,

Robert

Coordinator
Dec 7, 2010 at 12:40 AM
Edited Dec 7, 2010 at 12:41 AM

If you are using the GetEntriesXml function to get data, you probably have two parameters on that function named OrderByField and OrderAscending - if you do, try setting them to the date field and 'false'.

Dec 7, 2010 at 12:42 AM

*sigh*

So simple.

Thanks once more Marcus.

Coordinator
Dec 7, 2010 at 12:46 AM

;-)

Feb 6, 2011 at 4:17 PM

Hi guys,


Is that possible to get a source code of Composite.Community.Blog.dll assembly ?


-Ruslan