We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 32046
    • 75 Posts
    ok, I have a TV which allows the client to select one of three different sidebars for use on a page. I want the sidebar content to be editable by the client. I’ve currently used a chunk but cannot find any way to allow the client to edit the chunk with giving them access to all other chunks, which is not an option. Also, using chunks does not allow rich text editing.

    So I’m now looking at creating three new resources (’news’, ’contactInfo’ and ’profile’), one for each of each of the three sidebars, which will allow the client to [rich-text] edit the content of the sidebars.
    My TV to select which sidebar is included in a page is [*leftSidebar*]

    However, I’m now stuck as to how to go about including the sidebar resource inside another resource (for example the homepage).
    Anyone?
      • 3749
      • 24,544 Posts
      You could use the getField snippet to get the "content" field of each document.

      You could also use a custom snippet:

      [!GetContent? &docID=`##`!]


      Where ## is the ID of the *unpublished* document and this is the GetContent snippet:


      $doc = $modx->getDocument((string)$docID, 'content', 0); // Un-published -- third argument should be 1 if published
       return $doc['content'];
        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
        • 32046
        • 75 Posts
        Thanks BobRay,

        I have chosen the second path you offered with your custom snippet. My call is

        [!GetContent? &docID=`[*leftSidebar*]`!]


        where leftSidebar is my TV - a dropdown type with input values of:

        Latest news and events==75||Contact details==76||Why Us?==77


        but I’m getting no output. I’ve echoed the var $docID in the snippet and it’s empty. Is my TV set up incorrectly?
          • 3749
          • 24,544 Posts
          Everything looks right to me. Double check all the spellings, they’re case-sensitive.

          Try putting the TV tag in the document to see if it holds the correct number:

          <p>leftSideBar Doc ID: [*leftSideBar*]</p>
            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
            • 32046
            • 75 Posts
            Thanks BobRay,

            Everything was indeed correct, however I had a default value of 75 set in the TV, and for some reason it prevented that value being entered into the database table "modx_site_tmplvar_contentvalues" when selected.

            I tried everything and it simply will not enter 75 into the table - The other values enter fine. When selecting the 75 value modx simply removed the row from the table corresponding to that pages particular TV. I removed the default setting and left it blank and the value 75 is now entered just fine.

            Don’t know if this is a bug (presume not) or if there is no entry in the database table modX just assumes that pages TV value to be equal to the TVs default, but it does make it difficult to work with in this case, using $modx->getDocument().
              • 3749
              • 24,544 Posts
              I don’t know what would cause that unless there was a space next to the 75 or possibly the question mark in the TV was confusing things.

              Glad you got it working. smiley
                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
                • 9207 ☆ A M B ☆
                • 2,475 Posts
                I would bet that the question mark was throwing off the parser.... ampersands throw it off too (at least historically they did) because they delineate new variables.
                  • 28042 ☆ A M B ☆
                  • 24,524 Posts
                  Yes, you cannot have ? & or = in (Evo) snippet parameters, and that includes any inner TVs or snippets that you use as values for parameters. The inner TV or snippet is evaluated, and its return value is used as the parameter value for the outer original snippet. So if the inner TV or snippet returns one of the three "reserved" characters, the main snippet call will fail (or at least not behave as expected).
                    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