We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 51347
    • 82 Posts
    Thats my new try:

    HTML:
    <img src="assets/images/[[!lingua.getValue? &id=`[[+id]]` &field=`mynumber`]]/[[lasturl]]">


    Snippet: lasturl
    <?php
    $path_parts = pathinfo('assets/images/12345/myimage.jpg');
    echo $path_parts['basename'], "\n";


    Output:
    assets/images/ 12345 / myimage.jpg

    It works with the url in snippet. But if i try to set TV "picture" in my snippet:

    Snippet: lasturl
    <?php
    $path_parts = pathinfo('[[!lingua.getValue? &id=`[[+id]]` &field=`picture`]]');
    echo $path_parts['basename'], "\n";


    then i get:
    assets/images/ 12345 / assets/images//myimage.jpg


    Need help, please.

      • 4172
      • 5,888 Posts
      why are you using lingua.getValue at all?
      Are this TVs, which are translated?
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 51347
        • 82 Posts
        Yes, in the future.

        Thats the new Snippet:
        <?php
        $path_parts = pathinfo('[[+tv.picture]]');
        echo $path_parts['basename'], "\n";


        And it makes no difference:

        assets/images/ 12345 / assets/images//myimage.jpg
        • discuss.answer
          • 4172
          • 5,888 Posts
          what about:

          <?php
          $docid = $modx->getOption('docid',$scriptProperties,$modx->resource->get('id'));
          $tvname = $modx->getOption('tvname',$scriptProperties,$modx->resource->get('id'));
          $tvid = 0;
          $value = '';
          if ($tv = $modx->getObject('modTemplateVar',array('name'=>$tvname))){
              $tvid = $tv->get('id');
          }
          if ($tv = $modx->getObject('modTemplateVarResource',array('tmplvarid'=>$tvid,'contentid'=>$docid))){
              $value = $tv->get('value');
          }
          
          return str_replace('./','',$value);


          <img src="assets/images/[[+tv.mynumber]]/[[!getRawTVValue? &docid=`[[+id]]` &tvname=`picture`]] ">
            -------------------------------

            you can buy me a beer, if you like MIGX

            http://webcmsolutions.de/migx.html

            Thanks!
            • 51347
            • 82 Posts
            Thats it! Thank you so much Bruno!