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

    I am after a solution to the following - i’m still learning to bear with me smiley

    I have a ditto call which I am using a chuck to template the results. At the moment I just have the page title plus a link to the page. however I would also like the contents of the page to show, maximum characters 40.

    Can anyone help?

    thanks

    Lisa
      • 19369
      • 1,098 Posts
      I guess you’re using MODX Evolution, so try this:

      1. Install PHX Plugin
      2. Create this snippet:
      Snippet name: phx:character_limit
      Snippet Code:
      <?php
      if (strlen($output) > $options) {
            $output = $modx->stripTags($output, '');
            $output_cutted = substr($output, 0, $options);
            $last_space = strrpos($output_cutted, " ");
            $output = substr($output_cutted, 0, $last_space) . "";
            } else {
            $output = $modx->stripTags($output, ''); 
            }
            return $output;
      ?>


      3. Usage:
      [+content:character_limit=`180`+]