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

    I have a site with 2 contexts (multi domain).
    There is a getResources-call in context2 that call resources from context1. Inside, it have a imageTV.
    But the images do not appear (Error 403 forbidden)

    What do i have to do to get it work?

    This question has been answered by BobRay. See the first response.

      • 17301
      • 932 Posts
      I think you need to check it inside the access permissions tab when editing the TV.
        ■ email: [email protected] | ■ website: https://alienbuild.uk

        The greatest compliment you can give back to us, is to spend a few seconds leaving a rating at our trustpilot: https://uk.trustpilot.com/review/alienbuild.uk about the service we provided. We always drop mention of services offered by businesses we've worked with in the past to those of interest.
        • 49710
        • 92 Posts
        What do I have to check there?
          • 17301
          • 932 Posts
          Sorry lchris89 I'm struggling with this one, just spent the last 30 minutes trying it on a local dev server myself with no luck.

          I don't actually think this is supported by getResources/pdoResources. Though this might shed some light on a potential work around:

          https://forums.modx.com/thread/78156/symlinks-getresources#dis-post-516892
            ■ email: [email protected] | ■ website: https://alienbuild.uk

            The greatest compliment you can give back to us, is to spend a few seconds leaving a rating at our trustpilot: https://uk.trustpilot.com/review/alienbuild.uk about the service we provided. We always drop mention of services offered by businesses we've worked with in the past to those of interest.
          • discuss.answer
            • 3749
            • 24,544 Posts
            I don't know if this would work, but it's worth a try. It should bypass any permission issues.

            Put this tag where the image would go in the Tpl chunk:

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


            Then create a snippet called getImage with this code:

            <?php
            $tvId = 12; // replace with the id of the image TV
            $docId = $modx->getOption('docId', $scriptProperties);
              
            if (empty($docId)) {
                $output = 'NO DOC ID';
            } else {
                $c = array(
                    'tmplvarid' => $tvId,
                    'contentid' => $docId
                );
                $tvr = $modx->getObject('modTemplateVarResource', $c);
                if ($tvr !== null) {
                    $output = $tvr->get('value');
                } else {
                    $output = 'Could not get TemplateVarResource';
                }
            }
              
              
            return $output;




            [ed. note: BobRay last edited this post 9 years, 3 months ago.]
              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
              • 52064
              • 120 Posts
                FerX - Developer at Eracom s.r.l.
                • 17301
                • 932 Posts
                Yep that works Bob smiley
                I had to edit the snippet slightly to parse

                <?php
                $tvId = 8; // replace with the id of the image TV
                $docId = $modx->getOption('docId', $scriptProperties);
                 
                if (empty($docId)) {
                    $output = 'NO DOC ID';
                } else {
                    $c = array(
                        'tmplvarid' => $tvId,
                        'contentid' => $docId
                    );
                    $tvr = $modx->getObject('modTemplateVarResource', $c);
                    if ($tvr !== null) {
                        $output = $tvr->get('value');
                    } else {
                        $output = 'Could not get TemplateVarResource';
                    }
                }
                 
                 
                return $output;
                  ■ email: [email protected] | ■ website: https://alienbuild.uk

                  The greatest compliment you can give back to us, is to spend a few seconds leaving a rating at our trustpilot: https://uk.trustpilot.com/review/alienbuild.uk about the service we provided. We always drop mention of services offered by businesses we've worked with in the past to those of interest.