We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 9207 ☆ A M B ☆
    • 2,475 Posts
    Aha. Upgrading to 2.1.3-pl fixed this. Why didn't I notice that earlier?

    Ok, the followup question here is whether or not it's possible to update the display in the manager so the user sees the new value?
      • 3749
      • 24,544 Posts
      Let's back up. Try putting this as the entire plugin code and see what happens:

      <?php
      $x = 5;


      Maybe it's not your code at all. If it still hangs, the problem is elsewhere.

      Also, check to make sure you can save documents at all (with the plugin disabled).

        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
        • 9207 ☆ A M B ☆
        • 2,475 Posts
        Thanks Bob, it did have to do with version 2.0.8 somehow. Throughout this I would disable the plugin or comment out its contents to check whether or not the document could save, so I knew it was my plugin. Upgrading to 2.1.3 fixed things.
          • 3749
          • 24,544 Posts
          Did you ever try manually deleting the files in the core/cache directory? Some of the early 2.x versions had trouble with corrupted cache files.
            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
            • 9207 ☆ A M B ☆
            • 2,475 Posts
            Hmm... no, I didn't try that. Perhaps the upgrade deleted those files, and maybe that's what fixed this instead of the upgraded files themselves.
              • 38000
              • 19 Posts
              I stumbled upon this entry of yours while searching for a solution to a problem I have. And I wonder if you could help me with the problem of mine. I try to describe my situation:

              We have a home page. On it there are several getResources-calls to get the content of several articles-folders. Except for the plain text we don't save the content directly with the particular resources but have another folder and child resources in it. It's a bit similar to a database structure. We had a working solution in Evolution. So we do have a drop down element for a tv named games with the particular resources. This is the "link" between the text and the so to speak database-resource. We did it this way so we could re-use news-pictures, tags, etc. pp. several times and don't have to add them manually to every news we write.

              In evolution we had a ditto tpl and used a snippet for example to get the game's news-picture. We called it like this:

              [[gamesArticlePictureUrlDitto? &id=`[+id+]` &template=`[+template+]`]]


              The snippet startet with a code like this:

              <?php
              $id = isset($id) ? $id : $modx->documentObject['id']; 
              $template = isset($template) ? $template : $modx->documentObject['template'];
              
              //check if it is the old or new tpl
              if($template != 34) { 
              //it is the old
              $pic = $modx->getTemplateVarOutput('newsbild',$id); 
              return $pic['newsbild']; 
              }
              
              //getting the data of the packshot tv
              $pic = $modx->db->query('SELECT tvv.value AS picture FROM modx_site_tmplvar_contentvalues AS tvv LEFT JOIN modx_site_content AS sc ON (tvv.contentid = sc.id) WHERE sc.id = (SELECT value FROM modx_site_tmplvar_contentvalues WHERE contentid = '.$id.' AND tmplvarid = 60) AND tvv.tmplvarid = 63');
              $pic = $modx->db->getRow($pic);
              $pic = $pic['picture'];


              It's not finished there but in revolution we don't even get as far as this.

              We do have a new snippet now, and in our "getResources"-tpl we call it like this:

              [[gamesArticlePictureUrl? &id=`[[+id]]` &template=`[[+template]]`]]


              The revolution snippet starts like this:

              <?php
              $id = isset($id) ? $id : $modx->resource->get('id'); 
              $template = isset($template) ? $template : $modx->resource->get('template');
              
              print_r($id);
              print_r($template);


              The only thing that is output is the template and id of the home page and not of the different resources that are aggregated by getResources.

              Is there perhaps an easier way to get to those values of the resources aggregated? And then again could we reach out in a different way to the value of this database resources? In Evolution it did not work out. We had to use these database queries but since Revolution uses objects it might be possible to reach out <-- and here I am at your particular anser in this thread, with this "modTemplateVarResource"... this might be a way to reach those "far" objects/resources' values.

              Thanks in advance for sharing your thoughts on this.
                • 3749
                • 24,544 Posts
                It might work to call the snippet uncached in the Tpl chunk:

                [[!gamesArticlePictureUrl . . .]]


                But it might be more efficient to pull the articles yourself:

                [[!GetArticles? &parent=`12`]]



                <?php
                /* GetArticles Snippet */
                
                $tvId = '33';
                
                $fields = array(
                   'published'='1',
                   'deleted'='0',
                   'parent'=$scriptProperties['parentId'],
                };
                
                $articles = $modx->getCollection('modResource', $fields);
                
                foreach ($articles as $article) {
                
                   $tvValue = $article->getTVValue($tvId);
                
                }



                ---------------------------------------------------------------------------------------------------------------
                PLEASE, PLEASE specify the version of MODX you are using . . . PLEASE!
                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
                  • 9207 ☆ A M B ☆
                  • 2,475 Posts
                  It's worth noting here that the plugin will hang if you tie it to the OnBeforeDocFormSave event. It must be attached to the OnDocFormSave event for setTVValue() function to work. [ed. note: Everettg_99 last edited this post 13 years, 11 months ago.]