We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 5206
    • 10 Posts
    I want to have a chunk that takes a property and then passes it on to a tv that is doing an @RESOURCE call. thus:

    on the page:

    [[$myChunk? &valuetopass=`42`]]

    and then in the chunk:

    ...some formatting...
    [[*myTV? &docid=`[[+valuetopass]]`]]
    ...some more formatting...

    and then in the TV:

    @RESOURCE [[+docid]]

    on the page the chunk is showing the formatting wrapped around the tv but not the resource bound through the tv. In the docs I see lots of commentary about passing properties to chunks as TV’s but not anything about passing properties into a chunk that is then passed on into a TV. is this not possible? If not, how would I go about achieving the same effect?

    thanks,
    --ChrisM
      • 3749
      • 24,544 Posts
      I’m not sure that’s possible. You might try doing away with the TV and putting a getResourceField tag in the chunk, using [[+valuetopass]] as a property value.
        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
        • 5206
        • 10 Posts
        Thanks, Bob, that worked great.

        So to end the conversation, always the contribution:

        How to make a client(customer)-friendly dynamic sidebar:

        packages needed:
        getResource
        getPage

        1. create a container resource and name it Sidebar. check the Hide from menus option and save.
        2. create the tpl chunk you will link to in getPage. the template is a content box for your sidebar. thus here i’m calling it tplSidebarBlock such as:
        <div class="sidebar-box">
        [[+content]]
        </div>
        

        *remember to use +content, as you’re pulling from the snippet, not from *content. if you do *content instead you will duplicate the displaying page’s content.
        3. create a TV to house your getPage call (in this case I’m calling it sidebarBlock):

        [[!getPage?
           &elementClass=`modSnippet`
           &element=`getResources`
         
           &parents=`[[+sidebarFolder]]`
           &depth=`2`
           &limit=`10`
           &pageVarKey=`page`
         
           &includeTVs=`1`
           &includeContent=`1`
           &showHidden=`1`
           &tpl=`tplSidebarBlock`
        ]]
         


        4. fit the TV into the part of your template that the sidebar content goes (note the sidebarFolder should be the id of Sidebar):

        <div class="sidebar">
        [[*sidebarBlock? &sidebarFolder=`5`]]
        </div>
        


        5. create a resource under Sidebar with text you want to post in your sidebar.

        et viola! Makes it so people who are going to be adding pages but know nothing about CMS systems can understand.

        --ChrisM