Sahil Shah
Sahil Shah

Reputation: 95

In Composite C1, How to apply same blog application/module to multiple pages

I have successfully added a blog application to a new page called "Blog". Now I have a different "AboutUs" page on which I want a list of latest five blogs postings. For this I created a new XSLT function similar to Community.Blog.Renderer which can display the blogs as per my requirement.

Next, I added blog application to "AboutUs" page. But it seems this is a different application. What I want to achieve:

  1. A small widget on "AboutUs" page that displays list of latest 5 blogs posted on the "Blog" page.
  2. A "Read More" button in each such widget, which when clicked will redirect to the corresponding blog on the "Blog" page.

I am new to composite C1 and till this far I have liked it very much. I hope, composite C1 can handle my requirements somehow and doesn't let me down. Appreciating your concern.

Upvotes: 2

Views: 380

Answers (1)

Sahil Shah
Sahil Shah

Reputation: 95

For keeping this thread clean, here is the answer posted by Inna on codeplex discussion forum:

You can achieve this by creating a simple XSLT:

  1. Create XSLT for example named Composite.Community.Blog.Latest
  2. On the Function Call tab add two functions "Composite.Community.Blog.Entries.GetEntriesXml" and "Composite.Community.Blog.XsltExtensions", Source code like this

    <f:functions xmlns:f="http://www.composite.net/ns/function/1.0">
    <f:function name="Composite.Community.Blog.Entries.GetEntriesXml" localname="GetEntriesXml">
        <f:param name="PropertyNames">
            <f:paramelement value="Date" />
            <f:paramelement value="Teaser" />
            <f:paramelement value="PageId" />
            <f:paramelement value="Id" />
            <f:paramelement value="Title" />
        </f:param>
        <f:param name="OrderByField" value="Date" />
        <f:param name="OrderAscending" value="False" />
        <f:param name="PageSize" value="5" />
    </f:function>
    <f:function name="Composite.Community.Blog.XsltExtensions" localname="XsltExtensions" />
    </f:functions>
    

    Make sure that GetEntriesXml's Selected Fields contain PageId, Date and Title fields, you will need them to generate Blog Entry URL.

  3. On the Template tab you will have something like this:

    <?xml version="1.0" encoding="UTF-8"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:in="http://www.composite.net/ns/transformation/input/1.0" xmlns:lang="http://www.composite.net/ns/localization/1.0" xmlns:f="http://www.composite.net/ns/function/1.0" xmlns="http://www.w3.org/1999/xhtml" xmlns:be="#BlogXsltExtensionsFunction"  exclude-result-prefixes="xsl in lang f be">
        <xsl:template match="/">
        <html>
            <head></head>
            <body>
                <ul>
                    <xsl:for-each select="/in:inputs/in:result[@name='GetEntriesXml']/Entries">
                        <li>
                            <h3>
                                <xsl:value-of select="@Title" />
                            </h3>
                            <p>
                                <xsl:value-of select="@Teaser" />
                            </p>
                            <a href="~/page({@PageId}){be:GetBlogUrl(@Date, @Title)}">Read more...</a>
                        </li>
                    </xsl:for-each>
                </ul>
            </body>
        </html>
        </xsl:template>
    </xsl:stylesheet>
    
  4. Then insert this XSLT where you want to show list of the 5 latest blog entries. (note: you should not to add blog application to the page where you want to show list of latest entries.)

Upvotes: 2

Related Questions