We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 16574
    • 49 Posts
    I’m trying to use the following with the modx API

    $Array = $modx->getTemplateVarOutput(’testeImg’, 21);

    but get this error

    Warning: DocumentParser::include_once(manager/includes/tmplvars.format.inc.php) [function.DocumentParser-include-once]: failed to open stream: No such file or directory in C:\xampp\htdocs\modx\modx-0961p2\manager\includes\document.parser.class.inc.php on line 1888
    
    Warning: DocumentParser::include_once() [function.include]: Failed opening 'manager/includes/tmplvars.format.inc.php' for inclusion (include_path='.;C:\xampp\php\pear\') in C:\xampp\htdocs\modx\modx-0961p2\manager\includes\document.parser.class.inc.php on line 1888
    
    Warning: DocumentParser::include_once(manager/includes/tmplvars.commands.inc.php) [function.DocumentParser-include-once]: failed to open stream: No such file or directory in C:\xampp\htdocs\modx\modx-0961p2\manager\includes\document.parser.class.inc.php on line 1889
    
    Warning: DocumentParser::include_once() [function.include]: Failed opening 'manager/includes/tmplvars.commands.inc.php' for inclusion (include_path='.;C:\xampp\php\pear\') in C:\xampp\htdocs\modx\modx-0961p2\manager\includes\document.parser.class.inc.php on line 1889
    
    Fatal error: Call to undefined function gettvdisplayformat() in C:\xampp\htdocs\modx\modx-0961p2\manager\includes\document.parser.class.inc.php on line 1897


    here is the code

    <?
    include_once('../modxapi.php');
    $page=$_GET["page"];
    $modx = new MODxAPI();
    $data = $modx->getDocument($page);
    $Array = $modx->getTemplateVarOutput('testeImg', 21);
    echo "<?xml version=\"1.0\"?>";
    echo "<pageData pub_date='".$data['pub_date']."'>";
    echo "<pagetitle>".$data['pagetitle']."</pagetitle>";
    echo "<longtitle>".$data['longtitle']."</longtitle>";
    echo "<menutitle>".$data['menutitle']."</menutitle>";
    echo "<content><![CDATA[".$data['content']."]]></content>";
    echo "</pageData>";
    ?>


    any suggestions?
      • 16574
      • 49 Posts
      can somebody move this post to another area? this isn’t quite 101
      thanks
        • 33372
        • 1,611 Posts
        I take it you’re loading the MODx API outside of MODx? I’m not sure that you can do that they way you’re trying to. Whenever I’ve thought that this would be a solution to a particular problem, I’ve found that I could actually do what I needed from within MODx and this caused far fewer headaches and issues.

        What exactly are you trying to do?

        [TOPIC MOVED]
          "Things are not what they appear to be; nor are they otherwise." - Buddha

          "Well, gee, Buddha - that wasn&#39;t very helpful..." - ZAP

          Useful MODx links: documentation | wiki | forum guidelines | bugs & requests | info you should include with your post | commercial support options
          • 16574
          • 49 Posts
          I’m trying to output the contents of a page in xml format. It works with all the code except with the gettemplatevaroutput call...

          Have you got any solutions
          share with me
          thanks
            • 33372
            • 1,611 Posts
            Right, but my question relates to whether/why you’re trying to do this outside of MODx. The errors you’re getting are due to trying to include the parser and API, not the specific getTemplateVarOutput function. You can certainly output an XML page like the one that you’re trying to create from within MODx without those errors, so I’m trying to figure out why you’re not doing that instead.
              "Things are not what they appear to be; nor are they otherwise." - Buddha

              "Well, gee, Buddha - that wasn&#39;t very helpful..." - ZAP

              Useful MODx links: documentation | wiki | forum guidelines | bugs & requests | info you should include with your post | commercial support options
              • 16574
              • 49 Posts
              I’m trying to output the xml to use in flash.
              I don’t want to mess around with templates.
              Is there another way to do that?
              If so... explain please.
                • 33372
                • 1,611 Posts
                Well, you can create a dynamic XML file from within MODx using a snippet. Flash doesn’t care how the XML file is generated, just that it has the information that it needs. So there’s no need to include the MODx API or anything else, since you’re already in MODx.

                So your snippet might be something like this:
                <?
                $output='';
                $page=$_GET["page"];
                $data=$modx->getTemplateVarOutput(array('pub_date','pagetitle','longtitle','menutitle','content','testeImg'),$page);
                $output.='<?xml version="1.0"?>';
                $output.='<pageData pub_date="'.$data['pub_date'].'">';
                $output.='<pagetitle>'.$data['pagetitle'].'</pagetitle>';
                $output.='<longtitle>'.$data['longtitle'].'</longtitle>';
                $output.='<menutitle>'.$data['menutitle'].'</menutitle>';
                $output.='<content><![CDATA['.$data['content'].']]></content>';
                $output.='<image>'.$data['testeImg'].'></image>';
                $output.='</pageData>';
                return $output;
                ?>


                Just make sure that you set the content type for the page to text/xml and call the snippet uncached and that should work fine within Flash.

                EDIT: I mistyped the content type as text/html before, which may have been confusing!
                  "Things are not what they appear to be; nor are they otherwise." - Buddha

                  "Well, gee, Buddha - that wasn&#39;t very helpful..." - ZAP

                  Useful MODx links: documentation | wiki | forum guidelines | bugs & requests | info you should include with your post | commercial support options
                  • 16574
                  • 49 Posts
                  where do I call the snippet on the page where the contents are?

                  like:
                  [[!askFlash]]
                  contentOverHere


                  in this way it will output the <xml... inside the page.
                  how do I get the xml only

                  sorry for nagging
                    • 33372
                    • 1,611 Posts
                    No worry about nagging... If you use the blank template MODx will only output whatever is in the content field. So if that’s your snippet, then that’s what will be outputted.
                      "Things are not what they appear to be; nor are they otherwise." - Buddha

                      "Well, gee, Buddha - that wasn&#39;t very helpful..." - ZAP

                      Useful MODx links: documentation | wiki | forum guidelines | bugs & requests | info you should include with your post | commercial support options
                      • 16574
                      • 49 Posts
                      I works great.

                      on some pages works fine.
                      on other the source is xml but displays as html don’t know why
                      and on other gives this error

                      The XML page cannot be displayed 
                      Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later. 
                      
                      
                      --------------------------------------------------------------------------------
                      
                      An invalid character was found in text content. Error processing resource 'http://127.0.0.1/modx/modx-0961p2/?id=25&page=3'...
                      
                      <?xml version="1.0"?><pageData pub_date="0"><pagetitle>Vestidos de Cerim