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

    Hi,
    I would like to create own TV. It should work like parent resource input of template.
    Any ideas?

    Where is source code file of this default input?
      • 3749
      • 24,544 Posts
      You may not need a TV. This tag will be replaced by the parent ID:

      [*parent*]


      or in Revolution

      [[*parent]]


      If that won’t do, you’ll have to explain exactly what you’re trying to accomplish.
        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
        • 11311
        • 3 Posts
        When creating a new document, you need to specify parent id.
        when you click Parent Resource input shows up the hint:
        Please select a node in the tree to the left.
        Next, you can select the document from tree and its value becomes input value.

        I would like to create this type of TV.
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          Ah, you mean to be able to click on the Tree and get that document’s ID inserted into the TV automatically.

          I don’t think there’s a way to get a TV to do that, unless you’re using the "custom TVs" modded version of Evo, although a custom ManagerManager extension might be able to pull it off; it’s all just javascript.

          I added the same feature to the URL field of weblinks some years ago. If you look at the manager/actions/mutate_content.dynamic.php file, between lines 213 and 270 you’ll find the original parent setting javascript and the additional link setting functions that I added for weblinks. Basically I used the same functions, just changed the names and the names of the fields involved from "parent" or "p" to "link" or "l". I didn’t worry about getting the item’s name to display like the Select Parent field needs to do.

          For using for a TV, you would need to implement these same two functions again for your specific TV field.

          It’s a bit trickier than it seems; first you have to use a trigger (like the set parent does by clicking the little documents icon next to the set parent field) to override the normal click behavior of the Tree, then another bit of javascript to get the ID value of the item clicked and load it into the appropriate field. Then click again on the little icon to restore the Tree’s default click function.
            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
            • 8643
            • 271 Posts
            PickDocsInTree -> http://modxcms.com/extras/package/608

            With this plugin you can in the text field of TV (Template Variable) to add documents (id), selecting them from the document tree site. Selected documents can be inferred on page with snippets Ditto or Wayfinder.
              • 28042 ☆ A M B ☆
              • 24,524 Posts
              That’s great! I was looking at making a custom widget for ManagerManager, which would do the same thing.
                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
                • 11311
                • 3 Posts
                thanks a lot!
                anyone try it in revolution if i need to rewrite it?
                Where can i find parent resource input source code in revolution?
                  • 28042 ☆ A M B ☆
                  • 24,524 Posts
                  I seriously doubt Revo needs any such kludge as this! Everything in Revo’s back-end is adjustable, customizable, fold-able, spindle-able, and mutilate-able!

                  The whole point is to access the Tree so you can just click on an item to get its ID into the TV value field. Revo probably has a function somewhere just for doing that wherever you want to.
                    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
                    • 3749
                    • 24,544 Posts
                    Quote from: sottwell at Jul 29, 2010, 11:40 AM

                    I seriously doubt Revo needs any such kludge as this! Everything in Revo’s back-end is adjustable, customizable, fold-able, spindle-able, and mutilate-able!

                    The whole point is to access the Tree so you can just click on an item to get its ID into the TV value field. Revo probably has a function somewhere just for doing that wherever you want to.

                    I haven’t tried it with TVs, but I think this would be drag-and-drop in Revo.
                      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