We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 16732
    • 592 Posts
    While I was trying to access to TVs for a specific doc with the getDocumentObject function, I found out that in line 929 in document.parser.class.inc.php, we have :
    $sql .= "LEFT JOIN " . $this->getFullTableName("site_tmplvar_contentvalues")." tvc ON tvc.tmplvarid=tv.id AND tvc.contentid = ’" . $this->documentIdentifier. "’ ";
    And It’s not working but with this :
    $sql .= "LEFT JOIN " . $this->getFullTableName("site_tmplvar_contentvalues")." tvc ON tvc.tmplvarid=tv.id AND tvc.contentid = ’" . $identifier . "’ ";
    We have access to the TVs values... So could you confirm to me if it is a bug or not ?

    thanks
      • 22303 MODX Staff
      • 10,725 Posts
      getDocumentObject is not an API function. It is internal only, i.e. should be a private method used only within the DocumentParser class itself.
        • 16732
        • 592 Posts
        Ok thanks for the answer.

        Is getDocument an API function ?
          • 22303 MODX Staff
          • 10,725 Posts
          Quote from: laurentc at Apr 12, 2007, 12:22 PM

          Ok thanks for the answer.

          Is getDocument an API function ?

          Correct; this kind of stuff will be much more apparent from the API documentation in 0.9.7. This has been an issue for quite some time, as it is hard to distinguish what is intended as public API, vs. private/protected implementation.
            • 16732
            • 592 Posts
            Great... so let use getDocument laugh

            Thanks Jason

              • 27376
              • 576 Posts
              The wiki has some basic documentation on which functions are API functions and which ones should be left alone.

              wiki.modxcms.com
                • 28042 ☆ A M B ☆
                • 24,524 Posts
                And also consider the difference between a snippet (to display stuff on the front-end) and a plugin (to modify the parsing process). A plugin may well need to use the "internal" functions and variables, such as the documentObject, because it is actually modifying the actions of the parser.

                The documentObject represents the HTML page that is sent to the web server, and will change as it goes through the various stages of parsing. To begin with it contains only the document’s assigned template with the snippet calls and other MODx tags that need to be evaluated. At the end, it’s displayed with a rather anti-climactic "echo" statement.
                  Studying MODX in the desert - http://sottwell.com
                  Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                  Join the Slack Community - http://modx.org
                  • 22303 MODX Staff
                  • 10,725 Posts
                  Quote from: sottwell at Apr 13, 2007, 01:11 PM

                  And also consider the difference between a snippet (to display stuff on the front-end) and a plugin (to modify the parsing process). A plugin may well need to use the "internal" functions and variables, such as the documentObject, because it is actually modifying the actions of the parser.
                  Actually, what you are describing is antithetical to the purpose of an API; though I agree that plugins can modify the parsing process, doing so should still be done through a prescribed, formal API. The fact is the getDocumentObject function should never be called by anything other than the core MODx engine itself. The documentObject variable it produces is public and available to plugins and other add-ons, but by definition, these not-so-clearly labeled "private" functions such as getDocumentObject(), mergeSnippetContent(), or cleanDocumentIdentifier() (just to name a few) should never be called by any add-on, snippet, plugin, module, or otherwise. Code that currently does this (and there are many examples), will need to be rewritten for future compatibility.

                  As for modifying actions of the parser by calling these internal functions, though possibly necessary to accomplish some more advanced features in the current codebase, this is simply a work-around and necessary evil for the time being. There are much better ways to override core functionality without risking upgrade paths. Unfortunately, these internal functions must be allowed to evolve with the changes to the core engine, or progress will become virtually impossible. As we will see when 0.9.7 becomes available, providing a custom parser class to override or provide new functionality is going to become not only possible, but very easy to do. This will become the preferred approach to extending or customizing the MODx parser, as well as many other parts of the core (i.e. session handling, error handling, etc).
                    • 28042 ☆ A M B ☆
                    • 24,524 Posts
                    Thank you for the most excellent explanation!

                    I am humbled before the master grin
                      Studying MODX in the desert - http://sottwell.com
                      Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                      Join the Slack Community - http://modx.org
                      • 10313
                      • 375 Posts
                      It seems that my question fits to the original question. But I’m not sure. Nevermind, here it is:

                      Is there an API-function like getDocument() that returns not only the values from ’site_content’ but also includes the TVs and their values?

                      Thx
                      Martin