We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 44922
    • 131 Posts
    I noticed that the ellipsis output modifier doesn't work for Chinese characters. Does anyone know if it is possible or if not, a work around? E.g. [[+introtext:ellipsis=`135`]] works on English language articles container tpl but is totally ignored if the content is Chinese.

    Thanks
      • 46886
      • 1,154 Posts
      Does the default work, i.e. [[+introtext:ellipsis]]

      This is interesting, try using limit..what else will truncate a long string?

      I am looking at some old project which used ellipsis, but i thought it did work even with Chinese characters here https://forums.modx.com/thread/96491/facebook-shares-inside-discuss#dis-post-525140

      Hmm seems I spoke too soon. I have to check my code, but in my twitter button the English works fine while the Chinese seems to error out, the www.twitter.com/intent... link won't resolve. I believe I only tested in English when i made this code. [ed. note: nuan88 last edited this post 10 years, 9 months ago.]
        • 3749
        • 24,544 Posts
        Make sure that all tables and fields in the database use the same character set as the one specified in the core/config/config.inc.php file (check on the structure tab in PhpMyAdmin).
          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
          Yikes that's a scary comment, is this likely to be a serious problem with collations or just a minor adjustment? Give it to me straight, please smiley
            • 3749
            • 24,544 Posts
            It depends on whether they match. wink

            There's more info here and a script to fix things, though I'm not sure it works on the current version of MODX.

            BTW, SiteCheck will check character set/collation of all tables and fields in the DB against the MODX config character set to see if they match (and perform a lot of other tests as well).
              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
              • 28042 ☆ A M B ☆
              • 24,524 Posts
              Does the Chinese text use spaces? The ellipsis modifier uses spaces for its breakpoints.
              $breakpoint = $usemb ? mb_strpos($output," ",$limit,$encoding) : strpos($output, " ", $limit);
              


              You might do better to use the "limit" modifier and add your own ellipsis dots afterwards.
                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
                Chinese text does *not* use spaces at all, as the punctuation is designed to add in a little space by itself.

                I will try that limit to see how it works, that could well be the problem. Easier then messing with config files, for me.
                  • 3749
                  • 24,544 Posts
                  Remember that :limit can truncate the string in the middle of an HTML tag, so one of more closing tags could be missing and might break the page display. The :ellipsis modifier has code to prevent breaking inside a tag, but that may give you a longer string than you want.
                    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
                    Ok thanks Bob, let me play with it and maybe the original poster will jump in. I don't mean to hijack his or her thread, this is their issue not mine, I have enough on my plate with other stuff right now. My goal here is just to spur discussion and understanding.

                    For me this issue is breaking the button link entirely, people can't share my content, so I am less worried about something else breaking down the line. Also this is all text and any tags might get stripped anyway. So in my case this concern may be not very significant.

                    I am using this basic setup for my social buttons in Discuss, so its not a very typical case:

                    href="https://twitter.com/intent/tweet?text=[[+content_raw:ellipsis=`80`]]&url=[[+url]]&via="rayxilawforums"><img src="assets/components/bookmarkthis/images/v1.4/twitter.png"


                    Just as the original poster said, English content works fine but Chinese content doesn't ('totally ignored' for Chinese content). Hmm, lancipoos, does totally ignored mean that no limit is placed on the content, and you are getting too much content? Can you give us a little more info?

                    I think i have to use +content_raw because of Discuss, but I seem to remember some code like :strip_tags, which perhaps could avoid this problem, Bob could a modifier or limiter like strip_tags work to avoid the weaknesses of :limit? [ed. note: nuan88 last edited this post 10 years, 9 months ago.]
                      • 46886
                      • 1,154 Posts
                      :limit worked a treat for me!

                      I changed browsers for other reasons and would need to test it more fully to be absolutely sure, but the twitter link did resolve this time and I did get 80 characters including a couple spaces and numbers and punctuation, while before the link would not resolve and I could see the encoding of the Chinese characters in the link were all messed up in the url.