Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Nick 19 posts 39 karma points
    May 28, 2012 @ 11:01
    Nick
    0

    Recent comments box

    Hi there!

    I am trying to figure out how I would have a recent comments box and then grab some content into the template.

     

    I'm not sure if this will be a macro or xslt script, but this is what I need it to do;

    Client writes up some content > Then the most recent bit of content written by the client needs to be displayed in the template.

    I'm kind of stuck how to achieve this, can anyone point me in the right direction?

    Thank you!

  • Nick 19 posts 39 karma points
    May 29, 2012 @ 17:22
    Nick
    0

    I'm still trying to solve this, I had an idea if I could make a content folder then have a few folders then just select the bottom folder by ID and bring that content in, and call it "Latest" for the client to understand?

  • Chriztian Steinmeier 2800 posts 8790 karma points MVP 8x admin c-trib
    May 29, 2012 @ 21:48
    Chriztian Steinmeier
    0

    Hi Nick,

    I'm really not sure I understand this — do you need to grab whichever content that was last updated/created and show that somewhere on the website?

    Or is this only in the Backoffice?

    /Chriztian

  • Nick 19 posts 39 karma points
    May 30, 2012 @ 00:09
    Nick
    0

    Yeah your first idea, i need the client to be able to create comments (that will be displayed on the homepage) almost like a recent testimonials if you like, but only the last one the client puts into the backend will be shown.

    I hope that clears it up, thanks for your replies chriztian, very helpful!

    Cheers

  • Chriztian Steinmeier 2800 posts 8790 karma points MVP 8x admin c-trib
    May 30, 2012 @ 00:25
    Chriztian Steinmeier
    0

    OK, great - here's a recipe:

    Create a content folder for storing them and the actual Testimonial/Comment type - in XSLT you can do something like this to extract the latest automatically:

    <?xml version="1.0" encoding="utf-8" ?>
    <xsl:stylesheet
        version="1.0"
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        xmlns:umb="urn:umbraco.library"
        exclude-result-prefixes="umb"
    >
    
        <xsl:output method="xml" indent="yes" omit-xml-declaration="yes" />
    
        <xsl:param name="currentPage" />
        <xsl:variable name="siteRoot" select="$currentPage/ancestor-or-self::*[@level = 1]" />
    
        <!-- Select all the testimonial docs (use your actual doctype aliases here) --> <xsl:variable name="testimonials" select="$siteRoot/Testimonials//Testimonial" />
    
        <!-- To display the latest, we need to sort them backwards and take the 1st -->
        <xsl:template match="/">
            <xsl:for-each select="$testimonials">
                <xsl:sort select="@createDate" data-type="text" order="descending" />
                <xsl:if test="position() = 1">
                    <xsl:apply-templates select="." />
                </xsl:if>
            </xsl:for-each>
        </xsl:template>
    
        <!-- Template for the one to show -->
        <xsl:template match="Testimonial">
            <blockquote class="testimonial">          
                <xsl:value-of select="bodyText" />
            </blockquote>
        </xsl:template>
    
    </xsl:stylesheet>

    /Chriztian 

  • Nick 19 posts 39 karma points
    May 30, 2012 @ 11:03
    Nick
    0

    Thank you!

Please Sign in or register to post replies

Write your reply to:

Draft