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

    Running Revo 2.1.3pl.
    Have a blank template:
    [[!testing1234]]
    [[*promo_title]]
    


    Code in testing1234:

    $hello = $modx->resource->getMany('TemplateVars');
    foreach($hello as $failtown)
    {
        echo '<p>Name: '.$failtown->get('name').'| Value:'.$failtown->get('value').'</p>';
    
    }
    


    First time the page runs I see all TV's printed, and I see the last TV promo_title printed also.
    A cache file is generated.
    When I press F5, I get a list of all the TV's, but the values are blank!!! Whats weird is the promo_title is not. It has a value.

    Problem: Why are the TV's available in a template, but blank on the second load when I query them in a snippet?!?
    Have I gone mad?
      • 1778
      • 659 Posts
      Hi
      Did you try to simply call your TV uncached ?

      [[!testing1234]]
      [[!*promo_title]]  // just put an exclamation mark at the start of the call to make it uncached
      


      Not sure it solves your problem, but I think it could be a part of the problem....

      And to answer your question, yes TVs are avalaible in templates (they are TEMPLATES Variables after all)...

      Cheers
        • 15083
        • 697 Posts
        If I call the snippet cached...its fine....but thats not what I want!! I need to get the latest code from the Db each time...it fails after the first fetch?!?!
          • 22303 MODX Staff
          • 10,725 Posts
          You want the following to get the raw TV value in the Snippet:
          $failtown->getValue($modx->resource->id);


          Or this to get the fully processed output as would be rendered by the TV tag:
          $failtown->renderOutput($modx->resource->id);
            • 15083
            • 697 Posts
            TY, got it working smiley