We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 3749
    • 24,544 Posts
    Ah, I misunderstood what was in that TV.

    I think that should be:

    <meta name="description" content="[[*introtext:empty=`[[*content:strip_tags:limit=`200`]]`]]" />



    IMO, the ideal solution would be to make introtext a required field and skip the 'empty' modifier, but I don't know of any easy way to do it.



    ------------------------------------------------------------------------------------------
    PLEASE, PLEASE specify the version of MODX you are using.
    MODX info for everyone: http://bobsguides.com/modx.html
      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
      • 10208 ☆ A M B ☆
      • 1,780 Posts
      I switched out that line in the head, ran a test snippet and the result remains. If you want to see it, look at my test page at http://lilocounseling.com/lilomdx/frogabog-test.html

      The bandaid fix is to make sure to fill out the introtext field. However, for SEO purposes, and for when an end user changes the first few sentences, remembering to duplicate the changes in the introtext field isn't going to happen. Ideally it should just use the first 200 characters and leave it at that, whatever those characters are.
        Frogabog- MODX Websites in Portland Oregon
        "Do yourself a favor and get a copy of "MODX - The Official Guide" by Bob Ray. Read it.
        Having server issues? These guys have MODX Hosting perfected - SkyToaster
        • 3749
        • 24,544 Posts
        Hmm ... is there a snippet tag that renders the calendar in the first 200 characters of the content field? That would explain it if the snippet is parsed after the limit modifier (which I think it would be). If you call the snippet uncached, that may delay its processing and remove it from the output.


        ------------------------------------------------------------------------------------------
        PLEASE, PLEASE specify the version of MODX you are using.
        MODX info for everyone: http://bobsguides.com/modx.html
          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
          • 10208 ☆ A M B ☆
          • 1,780 Posts
          Yes, I just plunked the mxcalendar snippet into the content field, which is a good place for a calendar page normally, like many other snippet calls one might want to use. I guess I expected the output to be pulled into the 200 characters, but not displayed. The snippet is uncached already, so that's not the solution. hmmm... huh
            Frogabog- MODX Websites in Portland Oregon
            "Do yourself a favor and get a copy of "MODX - The Official Guide" by Bob Ray. Read it.
            Having server issues? These guys have MODX Hosting perfected - SkyToaster
            • 3749
            • 24,544 Posts
            Quote from: frogabog at Aug 06, 2012, 11:41 PM

            The bandaid fix is to make sure to fill out the introtext field. However, for SEO purposes, and for when an end user changes the first few sentences, remembering to duplicate the changes in the introtext field isn't going to happen. Ideally it should just use the first 200 characters and leave it at that, whatever those characters are.

            The only way to do that that I can think of is to write your own custom modifier that strips out MODX tags from the output, truncates it, and use the custom modifier instead of the limit modifier.

            I think this would do it (modified from code at http://rtfm.modx.com/display/revolution20/Custom+Output+Filter+Examples)):

            <?php
            $output = '';
            $options = !empty($options)?$options:50;
             
            if (!empty($input) && !empty($options)) {
              if (strlen($input) > $options) {
                 $input = preg_replace('/\x20*\[\[.*\]\]\x20*/', ' ', $input);
                 $input = preg_replace(
                 $output = substr($input, 0, strrpos(substr($input, 0, $options), ' '));
              }
              else{
                $output = $input;
              }
            }
            return $output;


            Create a snippet called mylimit with the code above and use just :mylimit after the striptags modifier. It defaults to 50 characters but you can use mylimit=`200` and it has the advantage of not truncating words.

            The new preg_replace was trickier than I expected. It replaces MODX tags and any spaces before and after them with a single space. Let me know if it works and I'll post it on the custom modifier page.

            BTW, I don't think there is a perfect solution. What you're trying to do isn't going to help much when a user forgets to update the introtext field, because it still may not be empty.


            ------------------------------------------------------------------------------------------
            PLEASE, PLEASE specify the version of MODX you are using.
            MODX info for everyone: http://bobsguides.com/modx.html [ed. note: BobRay last edited this post 14 years, 1 month ago.]
              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