We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 3749
    • 24,544 Posts
    I see what you mean. There are a couple other ways to go on this.

    1. Use a resource for the footer and use getResourceField to pull in the resource’s content field.

    2. Create one document to hold the values of all the pseudo-chunks as Rich Text TVs. Use a simple snippet to get the appropriate TV’s value from that resource with $tv->getValue() wherever you would have used the chunk tag. You can use form customization to hide all table but the TV tab for that resource and let the users edit there, or (with a little trickery), you could let them use NewsPublisher to edit them in the front end. If necessary, you could also create a different document for editing each TV and hide the others with form customization (though you’d have to adjust the snippet to get the value from the correct resource).

    I would probably do #2, though #1 involves less setup. Here’s a little more detail on #2:

    Create a document called Chunks (let’s say it has an ID of 12).
    Create a TV for each "pseudo-chunk" and attach it to the template used by the Chunks document. Call them "header," "footer," etc.

    When you want to display the content of one of them, use a tag like this which calls the following snippet:

    [[!ShowChunk? &chunkName=`footer`]]


    <?php
    /* ShowChunk snippet */
    $tv = $modx->getObject('modTemplateVar', array ('name'=>$chunkName));
    
    return $tv->getValue(12);


      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
      • 13275
      • 0 Posts
      Thanks you nailed it. Was doing some research and this article covers it quite nicely http://www.gregorysmart.com/2010/01/08/create-a-user-config-page-in-modx/ . Kind of allows you to use tvs in a global sense. They used getField but I think this is discontinued.

      I opted to use getresourcefield I did this call [[getResourceField? &id=`1` &field=`news_summ` &processTV=`1`]] . This way if the tv was created in document 1, I can use the tv in document 2 by calling the actual value of the tv in document.

      By the way this community is super fast in responding thanks again guys.
        • 3749
        • 24,544 Posts
        Quote from: [email protected] at May 21, 2011, 01:49 PM

        Thanks you nailed it. Was doing some research and this article covers it quite nicely http://www.gregorysmart.com/2010/01/08/create-a-user-config-page-in-modx/ . Kind of allows you to use tvs in a global sense. They used getField but I think this is discontinued.

        I opted to use getresourcefield I did this call [[getResourceField? &id=`1` &field=`news_summ` &processTV=`1`]] . This way if the tv was created in document 1, I can use the tv in document 2 by calling the actual value of the tv in document.

        By the way this community is super fast in responding thanks again guys.

        I’m glad you found something that works.

        BTW, I think the snippet I posted might be significantly faster and more efficient for this (though the actual time differences might be trivial), because it doesn’t have to retrieve the resource itself. I’m pretty sure getResourceField gets the resource, then gets the TV, then gets the TV value. Since you’re not using any of the resource’s content fields, the first step is unnecessary.
          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
          • 36440
          • 87 Posts
          Is there a simple solution? You know like just providing an update that would allow TinyMCE to edit a Chunk like Evo did (:P)? Or perhaps fixing ’which_element_editor’ System Setting to use TinyMCE as I have set? All this other stuff seems like nothing more than over-complicated hacks to solve what worked perfectly fine in Evo.

          If I have a News Chunk that appears site wide, I would like clients (and myself for that matter) to be able to easily edit it without having to introduce additional Resources, TVs, Form Customization yadda yadda yadda. Surely it doesnt have to be this complicated.

          Any help is very much appreciated.
            • 36440
            • 87 Posts
            OK so I got it working using what I guess is BobRays first example.

            First, download getResourceField snippet.

            I created a container resource which will hold all of the Chunks a client would edit. Within this container I created a resource called ’Footer’ which has an id of 26. I inserted my footer content and formatted how I like.

            In my template I added the snippet call [[getResourceField? &id=`26` &field=`content`]] and voila.

            So barring some further testing, as far as I can tell this is exactly what I was looking for.
              • 3749
              • 24,544 Posts
              I'm glad you got it working. Thanks for reporting back. smiley




              ------------------------------------------------------------------------------------------
              PLEASE, PLEASE specify the version of MODX you are using.
              MODX info for everyone: http://bobsguides.com/modx.html
                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
                • 9439
                • 90 Posts
                Nice. Just had a similar issue where a client wanted to edit a chunk. Getresourcefield works perfectly.

                thanks
                  David Heriot
                  pfsmedia
                • There's a fix for it.

                  http://tracker.modx.com/issues/4308

                  Edit file in /manager/assets/modext/widgets/element/modx.panel.chunk.js

                  replace

                  if (MODx.onLoadEditor) { MODx.onLoadEditor(this); }

                  with

                  if (MODx.config.use_editor && MODx.loadRTE) {
                  MODx.loadRTE('modx-chunk-snippet');
                  }
                    Developing Themes/Templates for MODx Revo. Visit http://mdxthemes.com