Copied to clipboard

Flag this post as spam?

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


  • Alex 3 posts 23 karma points
    Apr 29, 2010 @ 23:04
    Alex
    0

    "Read More.... " link

    Hi there,

    I'm installed Umbraco 4.03 a couple of days ago. How can I make the classic read more link, like news articles in other CMS (for example like in joomla)?

    Any suggestion are appreciated.

    Alessandro

  • bob baty-barr 1180 posts 1294 karma points MVP
    Apr 29, 2010 @ 23:25
    bob baty-barr
    0

    Alessandro,

    here is an example of some xslt i have written, with some explaining that you can use to expand...

    first the code

    <!-- The fun starts here -->

    <xsl:for-each select="$currentPage/node [string(data [@alias='umbracoNaviHide']) != '1']">

        <div class="newsTeaser">
            <h4><a href="{umbraco.library:NiceUrl(@id)}"><xsl:value-of select="./data[@alias='pageHeading']"/></a></h4>
            <xsl:variable name="shortText" select="umbraco.library:TruncateString(./data [@alias = 'bodyText'], '250', '')" />
            <xsl:value-of select="$shortText" disable-output-escaping="yes"/>
            <xsl:if test="string-length(./data [@alias = 'bodyText']) &gt; 250">
            <xsl:value-of select="concat('', '...&lt;/p&gt;')" disable-output-escaping="yes"/>
            </xsl:if>
        </div>
      
    </xsl:for-each>

    now some explaining :)

    this is a snippet i used to list some news teaser text on the news home page...

    i have my headline, the h4 tag with a link around it... you can duplicate this logic after the concat statment if you want.

    so, first i am setting a variable of shortext equal to a truncated version of my main text area [bodyText]--which i am truncating to a length of 250 characters.

    then i am outputting that truncated version-- the xsl value statment

    now, if the value of bodyText was longer than my original truncation amount it will do a concat operation to add a dot,dot,dot to the end... and ALSO a closing paragraph tag :) now, i am gambling that it isn;t truncating in teh middle of a tag, but hey, i am willing to make that gamble to close out the opening paragraph tag.

    so, if you wanted to... you could duplicate the h4 stuff i have, but make the text between the <a> tags read as Read More... llike this.

    <a href="{umbraco.library:NiceUrl(@id)}">Read More</a>

    hopefullly that gets you a start toward what you are wanting to do.

  • Alex 3 posts 23 karma points
    Apr 29, 2010 @ 23:42
    Alex
    0

    Bob,

    many thanks for your rapid reply.

    Let me try and see if I understood.:)

  • sina 1 post 21 karma points
    Dec 21, 2014 @ 16:59
    sina
    0

    Hi

    I don't understand how can I add Read More... link!

    I have to create a macro then when I create an article how I can I use this macro?

    Sina

  • Jan Skovgaard 11280 posts 23678 karma points MVP 11x admin c-trib
    Dec 21, 2014 @ 23:12
    Jan Skovgaard
    0

    Hi Sina and welcome to our :)

    What is your scenario?

    If you're using a read text editor you could add the read more link within it without having to define a macro for this purpose only.

    You should probably also consider using a sentence for the read more link, which makes more sense than just the "Read more text"...Read more about what? It does not always make sense unless you have a visual context, which the Google bot does not have for instance or a visually impaired person. Oh well that was just a site note :)

    /Jan

Please Sign in or register to post replies

Write your reply to:

Draft