We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 33706
    • 51 Posts
    Hi.

    How can I list the first 30 charactrs of a document with the ditto snippet?

    Here is what I have tried so far, but without great success :

    [!Ditto? &startID=`52` &truncLen=`30` &tpl=`NewsChunk`!]


    And here is my NewsChunk :
    <li>
    <p><a href="[*id*]">[+menutitle+]</a></p>
    <p>[+summary+]</p>
    </li>

    Should I use +summary+ or +content+ ?
    I would like to get data from the content of the document, not the summary(introtext).

    Thanks.

    Michel.
      • 3763
      • 155 Posts
      Hello!

      I had the same question smiley
      http://modxcms.com/forums/index.php/topic,4582.msg33483.html

      You have to add: &trunc=`0` (0 = full description, 1 = short/introtext)

      [!Ditto? &startID=`52` &trunc=`0` &truncLen=`30` &tpl=`NewsChunk`!]


      Enjoy, Ditto is really cool

      Regards, Boby.
        ...my Photo Gallery on Flickr...
        • 33706
        • 51 Posts
        Hi Boby.

        I can’t get what I need.

        I would like to have the first 30 characters of the content not the summary(introtext).
        I have tried all combinations.

        Any help. Please. Thanks.
          • 33337
          • 3,975 Posts
          Does your summary field empty ?
            Zaigham R - MODX Professional | Skype | Email | Twitter

            Digging the interwebs for #MODX gems and bringing it to you. modx.link
            • 33706
            • 51 Posts
            No my summary field is not empty.
              • 18397
              • 3,250 Posts
              If you want to truncate the content to 30 characters (thats quite short) use [+summary+] as that is the only element that is truncated but do not enter any introtext (summary) for that document. Ditto will switch to the content field automatically and shorten that. If you wish to do this make sure you remove the &trunc=0 as that turns truncation off altogether.
                • 22629
                • 194 Posts
                Hi guys,

                I’ve been trying for ages to do the same thing as Michel, but it doesn’t seem to want to work.

                What I want, is the last posted entry (1 only) from my folder, to display the title of the document, and the first 50 characters or so of the content field, and a "More..." link at the bottom to view the full document - Ditto should be more than capable, right?

                Here’s how I’m calling it:

                [[Ditto? &mode=`development` &startID=`14` &summarize=`1` &trunc=`1` &truncLen=`100` &truncText=`View full post` &emptyText=`Oops, looks like I’ve not made any journal posts this month yet!` &displayArchive=`0` &tpl=`webHL_Journal`]]

                My "webHL_Journal" chunk looks like:

                <b>[+pagetitle+]</b>
                <br /><br />
                [+summary+]


                (yet to add the link as I’m trying to get the summary working first!)

                Yet when I view the page, I get the whole document content.
                There is no summary (introtext) defined - only the page title, long title and menu title. I’ve looked through ditto’s code and can’t see any reason why it shouldn’t be doing exactly as I’m telling it to!
                If I change the truncLen to 50, it only shows about the first 15 characters of the document, if I set it to 70, it shows a bit more, but half a HTML tag.

                Also, did you know that the variable truncOffset is sometimes spelled as truncOffest and sometimes as truncOffset?
                  Andy Shellam | www.networkmail.eu | @Pandy06269 @NetworkMail

                  modx Revolution 2.2.6
                  Windows 2012 | IIS 8 | php 5.4.11 | MySQL 5.5.29

                  Content-Managed Websites Built on MODX
                  • 6777
                  • 13 Posts
                  It took me a while to work this out for myself. Not sure if you had found answer by now but here is how I got it working:

                  [[Ditto? &startID=`2` &summarize=`2` &total=`22` &commentschunk=`Comments` &tpl=`nl_blog_home` &paginate=`0` &alwaysshow=`1` &trunc=`1` &truncSplit=`0` &truncLen=`50`]]


                  The important varible is &truncSlit=`0`. By default this is set to `1` which it looks like it over-rides the truncation charactor settings, and uses some kind of default content splitting setting.

                  Regards, happy modx’in.
                    • 8120
                    • 10 Posts
                    yeah i am trying the same
                    http://modxcms.com/forums/index.php/topic,13260.msg87561.html#msg87561

                    so...if i dont fill in the "summary(introtext)" and use &truncLen=’50’ ...i dont know why...only the first word of the content will be shown.....if i use truncLen=’150’ the default value of the first 300charackters will be shown... ?!?? confusing....

                    edit:
                    and even when i am editing the summary.extender.inc and change the default value from 300 to whatever...nothing happens huh?
                      • 18397
                      • 3,250 Posts
                      The truncation function has a wandering ability so if you set it to 50 characters it will wander &truncOffset (30) either way by default to find the nearest end tag or end of word.