We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 17673
    • 194 Posts
    I just upgraded from 2.0.8 and find myself in deep s***T..

    1)
    the site homepage returns a nice, unstyled:
    Fatal error: Call to undefined method modX::getTemplateVarOutput() in/www/vhosts/.../modx/core/cache/includes/elements/modsnippet/22.include.cache.php on line 8

    I have a snippet with a ’$document_tvs=$modx->getTemplateVarOutput(true, $id);’ call (deprecated) how should I upgrade it exactly? (not clear from the http://rtfm.modx.com/display/revolution20/Summary+of+Legacy+Code+Removed+in+2.1 page)



    2)
    the manager acts weird, i.e. the Resources tree is empty (am I missing ’context’ somehow ?), Elements and Files are there.
    Every other page loads and lists items correctly.

    On the ’installation successful’ page I did get 2 warnings:

    [tt]Error updating table for class modUserGroup
    Array
    (
    [0] => 42S21
    [1] => 1060
    [2] => Duplicate column name ’rank’
    )

    Error updating table for class modUserGroup
    Array
    (
    [0] => 42000
    [1] => 1061
    [2] => Duplicate key name ’rank’
    )[/tt]

    Thanks, ciao
      ----------------------------------------------------------
      http://www.linkedin.com/in/lucapost/
      http://www.twitter.com/lukwe/
      ----------------------------------------------------------
      • 22303 MODX Staff
      • 10,725 Posts
      Quote from: lukwe at May 25, 2011, 11:24 AM

      1)
      the site homepage returns a nice, unstyled:
      Fatal error: Call to undefined method modX::getTemplateVarOutput() in/www/vhosts/.../modx/core/cache/includes/elements/modsnippet/22.include.cache.php on line 8

      I have a snippet with a ’$document_tvs=$modx->getTemplateVarOutput(true, $id);’ call (deprecated) how should I upgrade it exactly? (not clear from the http://rtfm.modx.com/display/revolution20/Summary+of+Legacy+Code+Removed+in+2.1 page)
      If you give us more context for how this deprecated API method is used, we can suggest the proper code to replace it. Can you post the Snippet code in a gist or other pastebin application?

      Quote from: lukwe at May 25, 2011, 11:24 AM

      2)
      the manager acts weird, i.e. the Resources tree is empty (am I missing ’context’ somehow ?), Elements and Files are there.
      Every other page loads and lists items correctly.
      Did you make sure to clear your browser cache? It could be cached JS. Can you provide more information on what distribution, PHP version, etc. so we can provide better help?
        • 24068
        • 4 Posts
        I only have an answer to your first question:

        Quote from: lukwe at May 25, 2011, 11:24 AM

        1)
        the site homepage returns a nice, unstyled:
        Fatal error: Call to undefined method modX::getTemplateVarOutput() in/www/vhosts/.../modx/core/cache/includes/elements/modsnippet/22.include.cache.php on line 8

        I have a snippet with a ’$document_tvs=$modx->getTemplateVarOutput(true, $id);’ call (deprecated) how should I upgrade it exactly? (not clear from the http://rtfm.modx.com/display/revolution20/Summary+of+Legacy+Code+Removed+in+2.1 page)

        $resource = $modx->getObject('modResource', $id);
        if($resource) {
            $tvs = array();
            foreach($resource->getMany('TemplateVars') as $templateVar) {
                $tvs[$templateVar->get('name')] = $templateVar->renderOutput($resource->get('id'));
            }
        }
        


        Could be optimized.
          • 17673
          • 194 Posts
          Quote from: OpenGeek at May 25, 2011, 11:38 AM


          If you give us more context for how this deprecated API method is used, we can suggest the proper code to replace it. Can you post the Snippet code in a gist or other pastebin application?


          I’ll post it here since it is a short one:
          $output = "";
               $document_tvs=$modx->getTemplateVarOutput(true, $id);
              
               $templatevar_output=$document_tvs['secondaryNav'];
          
            if ($templatevar_output){
             $params['parents']=$templatevar_output;
             $params['tpl']="SideColumnNews";
             $output = '<div class="subnav">'.$modx->runSnippet('getResources', $params).'</div>';
             
            }
           unset($document_tvs, $templatevar_output, $params);
          
          $modx->setPlaceholder('2ndNavUlLi', $output);
          
          return $modx->getChunk('sideMenuChunk');


          Quote from: OpenGeek at May 25, 2011, 11:38 AM


          Did you make sure to clear your browser cache? It could be cached JS. Can you provide more information on what distribution, PHP version, etc. so we can provide better help?



          Cache cleared, same behaviour; actually I noticed that when the page loads the little clickable arrow on the side of ’Web’ that is used for the tree briefly appears then is removed (?!).

          PHP Version 5.2.14-pl0-gentoo -mySql 5.0.90
          System Linux www 2.6.31-xen-r10-domU-02 x86_64




            ----------------------------------------------------------
            http://www.linkedin.com/in/lucapost/
            http://www.twitter.com/lukwe/
            ----------------------------------------------------------
            • 22303 MODX Staff
            • 10,725 Posts
            Here is a more proper approach for Revolution:

            <?php
            $output = "";
            /* use getObject() to get the modTemplateVar instance you want by name */
            $secondaryNav = $modx->getObject('modTemplateVar', array('name' => 'secondaryNav'));
            if ($secondaryNav) {
                /* use renderOutput() to get the processed value for the Resource with $id */
                $tvOutput = $secondaryNav->renderOutput($id);
                if (!empty($tvOutput)) {
                    $params = array(
                        'parents' => (integer) $tvOutput,
                        'tpl' => "SideColumnNews"
                    );
                    $output = '<div class="subnav">'.$modx->runSnippet('getResources', $params).'</div>';
                }
            }
            /* pass properties to the chunk to limit placeholder scope to that chunk */
            return $modx->getChunk('sideMenuChunk', array('2ndNavUlLi' => $output));
            


            In 2.1, you can further enhance performance by using the new modParser->getElement() method that takes advantage of the new modX->sourceCache; this will reduce database access with uncached Elements vs. using getObject()...
            <?php
            $output = "";
            /* use new getElement() method from the parser */
            $secondaryNav = $modx->parser->getElement('modTemplateVar', 'secondaryNav');
            if ($secondaryNav) {
                $tvOutput = $secondaryNav->renderOutput($id);
                if (!empty($tvOutput)) {
                    $params = array(
                        'parents' => (integer) $tvOutput,
                        'tpl' => "SideColumnNews"
                    );
                    $output = '<div class="subnav">'.$modx->runSnippet('getResources', $params).'</div>';
                }
            }
            return $modx->getChunk('sideMenuChunk', array('2ndNavUlLi' => $output));
            
              • 17673
              • 194 Posts
              Quote from: OpenGeek at May 25, 2011, 02:28 PM


              In 2.1, you can further enhance performance by using the new modParser->getElement() method that takes advantage of the new modX->sourceCache; this will reduce database access with uncached Elements vs. using getObject()...
              <?php
              $output = "";
              /* use new getElement() method from the parser */
              $secondaryNav = $modx->parser->getElement('modTemplateVar', 'secondaryNav');
              if ($secondaryNav) {
                  $tvOutput = $secondaryNav->renderOutput($id);
                  if (!empty($tvOutput)) {
                      $params = array(
                          'parents' => (integer) $tvOutput,
                          'tpl' => "SideColumnNews"
                      );
                      $output = '<div class="subnav">'.$modx->runSnippet('getResources', $params).'</div>';
                  }
              }
              return $modx->getChunk('sideMenuChunk', array('2ndNavUlLi' => $output));
              



              Pasted this in and the site immediately resurrected! (THANKS!)
              I promise I’ll spend some time studying the Revo API...

              I’ll look at the remaining manager issues tomorrow ( I don’t have full access to the files on the server from home), for now Firebug console is reporting a ’missing ) in parenthetical’ error on line eight of ext-all.js

                ----------------------------------------------------------
                http://www.linkedin.com/in/lucapost/
                http://www.twitter.com/lukwe/
                ----------------------------------------------------------
                • 17673
                • 194 Posts
                Solved the Javascript issue with an .htaccess hack, see http://modxcms.com/forums/index.php/topic,64953.0.html
                  ----------------------------------------------------------
                  http://www.linkedin.com/in/lucapost/
                  http://www.twitter.com/lukwe/
                  ----------------------------------------------------------