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

    i get only the option site_url and not the uri of the page. What i'm do wrong?

    (its my tvId wrong? I dont know the id of uri..)

        $resourceId = $unterseiteid; //$modx->resource->get('id') ??
        $tvId = uri;
      
        $query = $modx->newQuery('modTemplateVarResource', array(
        'contentid' => $resourceId,
        'tmplvarid' => $tvId,
        ));
        $query->select('value');
        return $modx->getOption('site_url') . $modx->getValue($query->prepare());
    
      • 3749
      • 24,544 Posts
      That will happen if the $resourceId or the $tvId are wrong. TvId must be a number (the number in parentheses next to the TV's name in the Elements tree).

      The $resourceId, may also be wrong (try it with the correct TV ID first), but fixing it depends on where and how the snippet is called. Since I think it's in a Tpl chunk, this might work:


      [[!snippetName? &docId=`[[+id]]` ]]


      Then in the snippet:

      $resourceId = $modx->getOption('docId', $scriptProperties);


        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
        • 51347
        • 82 Posts
        Thank you for your support.

        Quote from: BobRay at Nov 30, 2017, 11:03 PM
        (the number in parentheses next to the TV's name in the Elements tree)

        In the Elements tree i see only my tvs but not the regular tvs like uri, pagetitle, longtitle... Where i can see the tv for example "pagetitle"?


        If i set my tv (2) für tvId, then i get the same result.

        But i change the snippet and it works now:

        $tv = "uri";
        $id = "713";
        $parent = $modx->getObject('modResource', $id);
        return $modx->getOption('site_url'). $parent->get($tv);
        
        [ed. note: joe-petts last edited this post 6 years, 3 months ago.]
          • 4172
          • 5,888 Posts
          Resourcefields and Templatevariables are two different things.
            -------------------------------

            you can buy me a beer, if you like MIGX

            http://webcmsolutions.de/migx.html

            Thanks!
            • 51347
            • 82 Posts
            Ah ok. I messed things up..