We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 2369
    • 44 Posts
    I’m trying to implement a TV with a @CHUNK binding (in Evo) to produce a result, though I’m not sure if I’m on the right track.

    The goal:

    I’ve created a support folder of documents whose content I would like editors to add dynamically to a page on demand. I’ve created a multi-select list using a TV with the following SELECT query: @SELECT pagetitle,content FROM `modx_site_content` WHERE parent = ’158’

    The result is a multi-select list on the Edit Resource page(s) whereby editors can select a document(s) of their choosing to show up in a widgetized sidebar I’ve created with the TV output.

    The result:

    Currently this only partially works. The main content is pulled from the document(s) and populates the area I’ve specified. However no formatting or Page Title. I was hoping to bind this to a Chunk with the proper formatting so that both Page Title and Main Content will show up.

    Am I approaching this wrong? Is there another way. A better way? A correct way?

    Any help would be greatly appreciated!

    John
      • 3749
      • 24,544 Posts
      If I’m understanding you, it sounds like a perfect job for TV-based chunks. You put the chunks in a category, and the editor sees a list of them in the TV to select from.

      http://wiki.modxcms.com/index.php/Create_TV-Based_Chunks
        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
        • 2369
        • 44 Posts
        Thanks for the quick response BobRay. I’d actually stumbled across that very wiki article. I’m not sure if that’s what I want or not. Maybe it’s possible in conjunction to what I was intending.

        Since this is for end editors who won’t have access to chunk creation I need it to work with document resources instead.

        Basically I want the end editor to be able to create a document resource and then populate the content field and the page heading. These specified documents would then be accessible via a TV multi-select list on various templates. The end editor would select one or more of these documents to appear in a pre-designated area that I’ve set up such as a sidebar block. This is as far as I’ve gotten and it sort of works. The content field is displaying in the pre-specified area in the front end. However the page title isn’t showing up even though I’m pulling this from the database as well.

        I was also hoping to set up a container (<div class="block">Document info would go here</div>) for each document block (much like a Ditto call using a chunk as a container template).

        I thought that maybe a chunk binding would resolve this but I’m not sure.
          • 3749
          • 24,544 Posts
          Ok, I think I see what you’re trying to do. I could be wrong, but I don’t think @SELECT will get you there.

          The problem is that you need a placeholder for the pagetitle, but [*pagetitle*] will display the pagetitle of the current page, not the one being pulled in. The way Wayfinder, Ditto, etc. solve that problem is by using placholder tags: [+pagetle+] and replacing them with str_replace() in the snippet code.

          Here are some methods that might work:

          1. Use a separate Ditto tag for each section with a TV tag in one parameter specifiying the document to get and [+pagetitle+] and [+content+] in a Tpl chunk.

          2. Write a custom snippet that interprets the value of the TV, retrieves the resource, extracts the content and pagetitle, and sets custom placeholders for them -- e.g., [+MyContent+] [+MyPageTitle+].

          3. Use the getField snippetto get and display the pagetitle and content in separate calls.

          Hope this helps.
            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
            • 2369
            • 44 Posts
            Thanks for the help. That sounds like it could work. I’ll give it a shot.
              • 39190
              • 4 Posts
              Does it works on php 5.3.1 with Evolution 1.0.6 ?
              http://wiki.modxcms.com/index.php/How_To_Create_TV-Based_Chunks

              Thank You