We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 34926
    • 87 Posts
    I’m creating a theme in Wordpress that uses the MODx API (primarily for Wayfinder and the navigation) and am trying to find out how to render the contents of a TV. By that I mean the snippets actually run as opposed to being returned as plain text.

    Here is what I’m using to get the value of my "Footer" TV:
    $footer = $modx->resource->getTVValue("Footer");


    This works (probably as it should) but it contains Wayfinder snippets inside. Any ideas on an approach to get the Wayfinder snippets to run? If all else fails I can do this differently but I’m curious to know if its possible.

    Cheers

    Gibbs
      • 4172
      • 5,888 Posts
      may be this doesn’t process element-tags. I’m not sure about your situation. You can try to get the TV as object and try $tv->process() or put the result in a new modChunk and process that chunk.
      It should be possible to process the wayfinder-tags in your TV-content.
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 3749
        • 24,544 Posts
        I think you want this:

        <?php
        $tv = $modx->getObject('modTemplateVar', array('name'=>'footer'));
        
        $footer = $tv->renderOutput();


        Note that this will be a little faster if you know the ID of the TV (replace 12 with that ID):
        <?php
        $tv = $modx->getObject('modTemplateVar', 12);
        
        $footer = $tv->renderOutput();
          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
          • 34926
          • 87 Posts
          Thanks for the responses.

          I’ve tried both suggested methods and the snippets still display as text. A bit hacky but in the meantime I’m going to extract the snippets and use runSnippet.
            • 3749
            • 24,544 Posts
            Quote from: Gibbs at Jul 07, 2011, 03:34 AM

            Thanks for the responses.

            I’ve tried both suggested methods and the snippets still display as text. A bit hacky but in the meantime I’m going to extract the snippets and use runSnippet.

            That’s very odd. What happens if you just put the snippet tag in the page content? Is is possible that you’re using Evolution-style tags in the TV?
              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