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

    How can i pass/show the rest of the "ellipsed" text to a tooggle container in a dynamic way?? Is that possible? Probably this is simple but i need help!!! smiley

    The below code is just an example of what i need!

    Many thanks in advance and sorry about my english!!!

    <div class="content-intro>
    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit. Quisque justo sapien, pulvinar faucibus vehicula sed, mattis vitae diam. Sed at felis sit amet dui sollicitudin tincidunt ac et nunc. Etiam sagittis est sed ipsum congue egestas. Duis quis ...</p>
    
    <!-- Text generated by ellippsis -->
    
    </div>
    
    <div class="toggle">
    
    ... tellus in dui porta tristique eu ut neque. Donec non elit erat, ac aliquam sem. Fusce scelerisque venenatis sollicitudin. Ut porttitor mollis metus, nec pulvinar nisi ultricies nec.
    
    <!-- The rest of the text -->
    
    </div>
      • 4172
      • 5,888 Posts
      think you can use something like the substring-output-filter to split the text.
      http://rtfm.modx.com/display/revolution20/Custom+Output+Filter+Examples#CustomOutputFilterExamples-substring
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 3749
        • 24,544 Posts
        If you can build a unique identifier into your output filter and put an onclick attribute into it that contains that identifier, you should be able to toggle it with this JS:


        <script type="text/javascript">
        function toggleMe(a){
          var e=document.getElementById(a);
          if(!e)return true;
          if(e.style.display=="none"){
            e.style.display="block"
          } else {
            e.style.display="none"
          }
          return true;
        }
        </script>



        The toggle link and hidden div (all produced by the output modifier) would then look something like this:

        <a onclick="toggleMe(some_unique_string)">See the rest</a>
        
        <div id="some_unique_string" style="display:none">
            <p>Rest of the text</p>
        </div>



        ------------------------------------------------------------------------------------------
        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
          • 16899
          • 284 Posts
          Hi Bob
          I just want to pass the rest of the "ellipsed" text to a hidden div! t!!! smiley I have the plugin to do a toggle but i have no way to pass the cut content by ellipis to a container div. sad [ed. note: legues last edited this post 14 years, 4 months ago.]
            • 16899
            • 284 Posts
            Thanks a lot for your reply Bruno17! I´ll check the link now! smiley
              • 3749
              • 24,544 Posts
              Bruno17's custom output modifier will do that for you.


              ------------------------------------------------------------------------------------------
              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
                • 16899
                • 284 Posts
                Yes!!! I´m trying to put this working, but i don´t know how!!! Can you explain me how to do it? i´m not php expert!!! What i did was: create a snippet called substring with all the code:

                $output = '';
                $options = !empty($options)?$options:50;
                 
                if (!empty($input) && !empty($options)) {
                  if (strlen($input) > $options) {
                    $output = substr($input, 0, strrpos(substr($input, 0, $options), ' ')).' …';
                  }
                  else{
                    $output = $input;
                  }
                }
                return $output;
                
                $options=explode(',',$options);
                return count($options)>1 ? substr($input,$options[0],$options[1]) : substr($input,$options[0]);


                Then in my HTML i´m doing

                <div class="grid-6 last">
                
                [[*homepage-content-info:substring=`0,1`]]
                
                <div style="display:none;">
                [[*homepage-content-info:substring=`1`]]
                </div>
                
                </div>


                But it´s just showing me … output!!

                What i´m doing wrong?
                  • 3749
                  • 24,544 Posts
                  Line 12 is returning so you're never getting to lines 14 and 15. I think this would be an easier way with a new custom modifier snippet called split:


                  <div class="grid-6 last">
                   
                      [[*homepage-content-info:split=`50`]]
                   
                      <div style="display:none;">
                           [[+extra]]
                      </div>
                   
                  </div>
                  



                  <?php
                  /* split snippet */
                  $output = '';
                  $options = !empty($options)?$options:50;
                    
                  if (!empty($input) && !empty($options)) {
                    if (strlen($input) > $options) {
                      $output = substr($input, 0, strrpos(substr($input, 0, $options), ' ')).'&hellip;';
                      $modx->setPlaceholder('extra', substr($input, strlen($output)));
                    }
                    else{
                      $output = $input;
                    }
                  }
                  return $output;
                  

                    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
                    • 3749
                    • 24,544 Posts
                    BTW, I think you want the div ID on the hidden div, not the outer div.

                      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
                      • 16899
                      • 284 Posts
                      Yes yes!!!! Alright!!!!! It´s working!!! Perfect!!! Excelent!!! smiley Thanks a lot! How much do I owe you? LOL