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

    The little pieces of information I can find on the @Document binding normally state something like:
    The returned value is a string containing the content of the document

    Does anyone know what is meant by "content" - would that be the specific TV the @Document binding is on, all TVs in the document or just the built-in Content TV?

    I think I’m wrongly assuming that if I place a binding of "@Document 12" on a template variable called [*footer1*], that Modx will pull the content from [*footer1*] on document 12 - is that how it works?

    Just can’t seem to make it work - pulling my hair out here: http://modxcms.com/forums/index.php/topic,45946.0.html
      • 5532
      • 251 Posts
      Found these two pages which use custom snippets, although they grab chunks or snippets rather than content from TVs (maybe they could be modified?)
      http://modxdeveloper.com/blog/check-box-tv-toggle-display
      http://wiki.modxcms.com/index.php/Create_TV-Based_Chunks

      But after going through them, I can’t help feeling that I’m missing something big - surely there’s a quick way to get the content from a TV in one document into another document - that doesn’t involve snippets (or custom snippets)?

      At this stage (after a whole day) even a "no, it’s not possible to do that without a snippet" would be helpful.

      If the answer is no, does it make a difference to server load which snippet is used? i.e. would lots of Ditto calls be slower than lots of getField calls for example?
        • 27442
        • 103 Posts
        A TV named [*footer1*] with a default binding of @Document 12 will insert the [*content*] of resource 12 whereever it is called. For example:

        Lets say resource 12 contains this content (in the RTE field):
        Company name
        sreet address
        City, State, ZIP


        Some other document with the [*footer1*] TV contains something like:
        Welcome to our site.
        Some more text........
        [*footer1*]


        So then after parsing, this other document would appear in the client browser as:
        Welcome to our site.
        Some more text........
        Company name
        sreet address
        City, State, ZIP


        Hope that helps.
          • 5532
          • 251 Posts
          Hey Thanks for the reply,

          As you could tell by me ramblings I was getting desperate! I still don’t quite understand how it works as I think I had what you’re suggesting but the content from resource 12 wouldn’t show up when [*footer1*] was placed onto other pages.

          Firstly, when you mention an RTE field, is that a Rich Text Field?

          Here’s what I had:
          1. A TV called [*footer1*] which was ticked for my footer template
          2. In the "Input Option Values" or "Default Value" (I tested both but not at the same time) I had "@Docment 20"
          3. On document 20 had some text in the [*footer1*] TV
          4. I had a footer chunk with the [*footer1*] TV placed into it
          5. That chunk was then inserted into every template

          When I previewed the page, I was expecting the content from Document 20 to appear in the footer of any template that had the footer chunk in it.

          But maybe you’re saying that you can’t have the [*footer1*] TV in a chunk, it has to be on every page?

          Anyway, I had to give up and just go with a Ditto call but I would love to know how it actually works.

          Cheers

            • 3749
            • 24,544 Posts
            Maybe this will help.

            [*footer1*] on a page will be replaced by the value of that TV for the current page.

            If that TV contains @DOCUMENT 20, the tag will be replaced by the content field of document 20.

            If that TV contains a tag like this [*tag*] instead, it will always refer to that field for the current page.

            If you want the value of a TV from another page, you can use the GetField snippet or a snippet like Ditto that will get the other page’s TV value with a placeholder tag: [+tvName+] or a custom snippet that retrieves the TV value from the other page.

            Hope this makes sense.


              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
              • 27442
              • 103 Posts
              Quote from: cms at Feb 21, 2010, 01:48 PM

              3. On document 20 had some text in the [*footer1*] TV
              This is the part that’s off...... and also the part that I didn’t explain well initially. When using the @DOCUMENT 20 binding, it’s the actual content of document 20 that is inserted as [*footer1*]. Meaning the acutal content (wether using the rich text editor or plain text) of document 20. Document 20 doesn’t even need to have the TV [*footer1*]. Change the template of document 20 to blank (so no TV’s) and enter the footer text that you want into the body of this document.

              Reading that, it still isn’t as clear as I’d like, but I can’t seem to coherently explain what I’m trying to say :-(
                • 5532
                • 251 Posts
                Thanks guys,

                I feel like a complete idiot as I still don’’t quite understand!

                It seems as if the @Document binding doesn’t get content from the same TV, but rather, it only gets content from the default TV. So if you don’t use the default content TV on the document specified (as I don’t) then the @Document binding won’t return anything.

                Is that correct?

                Sorry!
                  • 27442
                  • 103 Posts
                  The @DOCUMENT binding is getting the document that is referenced, not a template variable that might (or might not) also be in that document. Think of it as a fancy chunk.
                    • 3749
                    • 24,544 Posts
                    Quote from: sjh_vt at Feb 24, 2010, 08:58 PM

                    The @DOCUMENT binding is getting the document that is referenced, not a template variable that might (or might not) also be in that document. Think of it as a fancy chunk.

                    Right. More precisely, it gets the resource content field of the specified document (not the document itself).
                      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