We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 46886
    • 1,154 Posts
    Hello, I am trying to set up sharing buttons in Discuss, which doesn't provide long titles or anything at the post level. The url is fine, but I want to provide several lines of contents as well.

    I have found that the placeholder of [[+content_raw]] works, at least with twitter, but it ends up pushing ALL of those contents, which is far, far too much. Strangely, [[+content]] doesn't work, it breaks the code.

    Anyway, I am looking for a way to start with [[+content_raw]] but limit it to a set number of characters, I would assume it could be something like [[+content_raw:limit=100]]...

    I am looking for other placeholders to use here, but haven't found any others so far.

    Could anyone help out with suggestions? Any help would be much appreciated.

    This question has been answered by sottwell. See the first response.

    • discuss.answer
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      [[+content_raw:limit=`100`]]

      You almost had it wink

      The "limit" modifier defaults to 100, so you could skip the whole =`100` bit.

      I have this prominently bookmarked, as I can never remember exactly how these go.

      You could also use
      [[+content_raw:ellipsis]]

      which defaults to 100 characters and adds the ... at the end.
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 46886
        • 1,154 Posts
        Looks like [[+title]] works as well, but I would like to get a little more contents out there, as the sharing is at the post level not the thread level.
          • 46886
          • 1,154 Posts
          Oh thank you so much Susan, yeah my instincts are getting better! Wow its so very easy when you "get" it, just a little bit!

          Thanks so much! I will put my sharing code over in Discuss section soon ;-)
            • 3749
            • 24,544 Posts
            A word of warning: if you use :filter and the break point occurs inside an HTML tag or a MODX tag, your page may look very strange.

            The :ellipsis filter has code to avoid that by closing any unclosed tags, but I don't know if it always works.

            If you're sure there are no HTML or MODX tags in the field, :filter will be much faster.
              Did I help you? Buy me a beer
              Get my Book: MODX:The Official Guide
              MODX info for everyone: http://bobsguides.com/modx.html
              My MODX Extras
              Bob's Guides is now hosted at A2 MODX Hosting
              • 46886
              • 1,154 Posts
              Yeah it seems this is a little dangerous, it has broken my page and even reverting back to the previous code hasn't fixed it. Its screwed up the font size and put a NULL in the top left corner.
                • 46886
                • 1,154 Posts
                actually I think it was the facebook code which broke things. That was scary! Reverting didn't fix it at first, yikes.
                  • 28042 ☆ A M B ☆
                  • 24,524 Posts
                  You might be able to do something like
                  [[+content_raw:striptags:ellipsis]]

                  then you'd have to provide styling in your own CSS.
                    Studying MODX in the desert - http://sottwell.com
                    Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                    Join the Slack Community - http://modx.org
                    • 46886
                    • 1,154 Posts
                    Ok thanks. This experimenting just broke Discuss quite comprehensively, and putting everything back isn't fixing it. Sigh.
                      • 46886
                      • 1,154 Posts
                      Ah turns out my friend was working on the site and I didn't know it. So I am going to assume all the errors are due to his work haha. Almost lost it for a second there.