We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 1570
    • 38 Posts
    Is it possible to manipulate the output of the YAMS snippet. For example:

    substr('[[YAMS? &get=`data` &docid=`'.$row1[id].'` &from=`introtext`]]', 0, 100);


    Say i need to output a substring of the introtext from multilingual docs, how can i go about doing that?

    I also tried using Output buffering but it doesn’t work well, probably because i dunno how to do it properly tongue

    ob_start();
    
    echo "[[YAMS? &get=`data` &docid=`$row1[id]` &from=`introtext`]]";
    
    $output = ob_get_contents();
    
    ob_end_clean();
    
    echo substr($output, 0, 100);


      • 4172
      • 5,888 Posts
      try this:

      <?php
      
      $params=array();
      $params['get']='data';
      $params['docid']=$row1['id'];
      $params['from']='introtext';
      
      $output = $modx->runSnippet('YAMS',$params);
      
      return substr($output, 0, 100);


        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 1570
        • 38 Posts
        Hi, thanks for the tip, i tired it however it outputs gibberish:

        (yams-select:22)(lang:22:en)Recently, popular Intertops casino, an online gambling site which is a part of the Microgaming Network, has planned a two-casino system in order to use alternative software(lang:22:de)..

        I think its because the YAMS snippet has to be run cached at all times.
          • 22851
          • 805 Posts
          Bruno’s idea was a good one. However, it doesn’t work in this case because the YAMS snippet actually outputs a special construct containing all language variants of the content that for embeddeding in the template. Truncating this output breaks the YAMS construct, hence the gibberish.

          It’s only during parsing of the template that the YAMS construct gets parsed and replaced by the correct language text.

          Your best bet for getting this to work is to install PHx as a plugin that is set to run after YAMS in the plugin event order. That way, after YAMS has finished doing it’s parsing, PHx can run, evaluating its own constructs and performing the truncation you are after.

          You should be able to use something like:
          [*phx:input=`[*introtext*]`:limit*]
          or, failing that
          [*phx:input=`((yams_data:[*id*]:introtext_(yams_lang)))`:limit*]


          You might find the following documentation on getting YAMS + PHx within Ditto snippets useful.
            YAMS: Yet Another Multilingual Solution for MODx
            YAMS Forums | Latest: YAMS 1.1.9 | YAMS Documentation
            Please consider donating if you appreciate the time and effort spent developing and supporting YAMS.
            • 1570
            • 38 Posts
            Hi PMS thanks for the reply, i tried it and it works perfectly smiley