We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
  • Been tinkering with the follow for hours and I can’t figure out what I’m doing wrong.

    I have TV called ’BannerPosition’ and I want it to resemble my site structure, for example:
    - Home
    - About us
    - Categories
    --- Category 0
    ------Subcategory 0.1
    ------Subcategory 0.1
    ------Subcategory 0.2
    ------Subcategory 0.3
    -- Category 1
    -- Category 2
    ------Subcategory 2.0
    ------Subcategory 2.1
    ------Subcategory 2.2
    ------Subcategory 2.3

    I want the the TV to show up as an indented checkbox-list.

    I used to use a chunk for that which outputs something like this:- Home||- About us||- Categories||--- Category 0||------Subcategory 0.1||------Subcategory 0.1||------Subcategory 0.2||------Subcategory 0.3||-- Category 1||-- Category 2------||Subcategory 2.0||------Subcategory 2.1||------Subcategory 2.2||------Subcategory 2.3||

    And then add: @CHUNK chunkname to the Input Option Values.

    If I add the output above in that chunk, everything works fine. But when I use getResources to generate that output, it all goes wrong and the only output I get when editing a document is the snippet-call: [[GetResources....]]

    Any help?
      Sterc Internet & Marketing | MODX Founding Partner | Chairman of the MODX Advisory Board

      In need of a MODX consult? Try our MODX Developers Experts!
      • 25979
      • 178 Posts
      Do you have getResources installed? Or do you use GetResources while usually it is called getResources?

      mike
        //Why use windows since there is a door?//
      • I have getResources installed and also used the lowercase-g in the snippet call.

        So, in short, I want this to appear:



        1. The banner position TV has the following Input Option Values: @CHUNK position-list
        2. The position-list chunk has the following content right now which renders the above screenshot:

        Page 1==1||Page 2==2||--- Page 3==3||--- Page 4==4||--- Page 5==5||------ Page 6==6||------ Page 7==7||--- Page 8==8||--- Page 9==9
        


        3. So now I want to resemble that using getResources. I’ll keep it simple and try to do one level.
        4. So I change the position-list chunk to:

        [[!getResources? &parents=`0` &depth=`1` &limit=`100` &tpl=`position-list-level1` &sortby=`menuindex` &sortdir=`ASC`]]
        


        5. position-list-level1 contains:

        [[+pagetitle]]==[[+id]]||
        


        6. This outputs the following in the TV:


        7. When I put the snippet-call in an empty page I get this (source code):

        Page1==1||
        Page17==17||
        Page22==22||
        Page2==2||
        


        That looks fine to me. The only thing I can come up with which is wrong, are the line breaks. Is there any way to get rid of those?
          Sterc Internet & Marketing | MODX Founding Partner | Chairman of the MODX Advisory Board

          In need of a MODX consult? Try our MODX Developers Experts!
          • 25979
          • 178 Posts
          it just came to me - you want the snippet render your site structure in manager or on your site? Because it looks for me you want it in your manager. Am I missing sth?

          mike
            //Why use windows since there is a door?//
          • Exactly, sorry for begin a bit vague wink

            I want it to appear this way (a TV in the manager):

              Sterc Internet & Marketing | MODX Founding Partner | Chairman of the MODX Advisory Board

              In need of a MODX consult? Try our MODX Developers Experts!
              • 22019
              • 390 Posts
              If you’re struggling with @CHUNK binding, you could always try @SELECT binding for now:

              @SELECT `pagetitle` AS `name`,`id` FROM `YOUR+DATABASE+NAMEsite_content` WHERE `parent` IN(X,XX,YY) 


              Clunky, but should work, as long as you know the parents of the tree nodes you want.
                Writer > E-consultant > MODx developer || Salesforce || modx 2.x || PHP 5.2.13 || MySQL client 5.0.86
                • 25979
                • 178 Posts
                hmm, so I have no idea smiley

                Mike
                  //Why use windows since there is a door?//
                  • 4971
                  • 964 Posts
                  Have you tried to @EVAL your snippet call? just a guess...
                  also you may need depth=`2` to go to the second level of
                  the tree...
                    Website: www.mercologia.com
                    MODX Revo Tutorials:  www.modxperience.com

                    MODX Professional Partner
                  • It just won’t run getResources. Not anywhere. I changed to ’Input Type: Dropdown’ to keep things simple. I’m 100% sure that dropdown menu’s render okay, so I’ll first try to populate a dropdown list TV using a getResources snippet.

                    I tried the following:

                    1. Input Option Value populating by using a chunk with a snippet inside it
                    Input Option Value: @CHUNK pagelist
                    Chunk pagelist:
                    [[getResources? &parents=`0` &depth=`1` &limit=`3` &tpl=`TVList` &tplLast`TVListLast` &sortby=`menuindex` &sortdir=`ASC` &outputSeparator=``]]
                    


                    TVList contains:
                    [[+pagetitle]]==[[+id]]||
                    


                    TVListLast contains:
                    [[+pagetitle]]==[[+id]]
                    


                    Result: an empty dropdown box


                    2. Input Option Value populating by using @EVAL with a snippet-call inside it
                    Input Option Value:
                    @EVAL return $modx->runSnippet('getResources', array('parents' => 0, 'depth' => 1, 'limit' => 3, 'tpl' => 'TVList', 'tplLast' => 'TVListLast', 'sortby' => 'menuindex', 'sortdir' => 'ASC', 'outputSeparator' => ''));
                    OR
                    Input Option Value: @EVAL { return $modx->runSnippet('getResources', array('parents' => 0, 'depth' => 1, 'limit' => 3, 'tpl' => 'TVList', 'tplLast' => 'TVListLast', 'sortby' => 'menuindex', 'sortdir' => 'ASC', 'outputSeparator' => '')); }
                    OR
                    Input Option Value: @EVAL echo $modx->runSnippet('getResources', array('parents' => 0, 'depth' => 1, 'limit' => 3, 'tpl' => 'TVList', 'tplLast' => 'TVListLast', 'sortby' => 'menuindex', 'sortdir' => 'ASC', 'outputSeparator' => ''));
                    OR
                    Input Option Value: @EVAL { echo $modx->runSnippet('getResources', array('parents' => 0, 'depth' => 1, 'limit' => 3, 'tpl' => 'TVList', 'tplLast' => 'TVListLast', 'sortby' => 'menuindex', 'sortdir' => 'ASC', 'outputSeparator' => '')); }
                    


                    Result: an empty dropdown box

                    3. Input Option Value populating by using @RESOURCE with a snippet inside it
                    Input Option Value: @RESOURCE 21
                    Resource 21 (document/page) contains:
                    [[getResources? &parents=`0` &depth=`1` &limit=`3` &tpl=`TVList` &tplLast`TVListLast` &sortby=`menuindex` &sortdir=`ASC` &outputSeparator=``]]
                    

                    Result: a dropdown box with the snippet call: '[[getResources? &parents=`0` &depth=`1` &limit=`3` &tpl=`TVList` &tplLast=`TVListLast` &sortby=`menuindex` &sortdir=`ASC` &outputSeparator=``]]''
                    OR
                    Resource 21 (document/page) contains - uncached:
                    [[!getResources? &parents=`0` &depth=`1` &limit=`3` &tpl=`TVList` &tplLast=`TVListLast` &sortby=`menuindex` &sortdir=`ASC` &outputSeparator=``]]


                    Result: a dropdown box with the snippet call: ’[[!getResources? &parents=`0` &depth=`1` &limit=`3` &tpl=`TVList` &tplLast=`TVListLast` &sortby=`menuindex` &sortdir=`ASC` &outputSeparator=``]]’


                    -----


                    If I run the above snippet calls on a page everything is fine. So my guess is that getResources does something wrong here....


                    ----

                    The following setup (without getresources) DOES work:
                    Input Option Value: @EVAL return $modx->runSnippet(’testlist’);
                    testlist snippet contains the output which the getResources call above outputs when called on a normal page:
                    echo 'Home==1||Pagenr2==2||Pagenr3==3';
                    


                    The result is how it should be, but I can’t get this to work with getResources...
                      Sterc Internet & Marketing | MODX Founding Partner | Chairman of the MODX Advisory Board

                      In need of a MODX consult? Try our MODX Developers Experts!
                      • 23214
                      • 36 Posts
                      Did you ever get a solution to this? I’m trying to do the same thing...