We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 40045
    • 534 Posts
    I didn't tell I think =)... but doesn't matter, your approach doesn't also work for me when I include the Text TV with default value [[*pagetitle]] as a normal TV in a Template (nothing MIGX), it just display the tag [[*pagetitle]] in the input field...like it's not processed at all...maybe I'm doing something wrong there? (I use revo 2.2.5)
      • 4172
      • 5,888 Posts
      what is with
       'parents'=>'0' 
      ?
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 40045
        • 534 Posts
        lol...didn't think about that^^ (would that work in any context, btw)?

        and it works perfectly, so my TV input options (TV type Select Box, single) entry looks like that:

        @EVAL $output = $modx->runSnippet('getResources',array('parents'=>'0','tpl'=>'@INLINE [[+pagetitle]]([[+id]])==[[+id]]','outputSeparator'=>'||','sortby'=>'pagetitle','sortdir'=>'ASC','limit'=>'0','showUnpublished'=>'1','showHidden'=>'1','depth'=>'3')); return 'Resource waehlen==||' . $output;


        and if you like to output a link directly (had some problems with that > giving me erros in log about not passing an integer to makeUrl()...that's why I include it here, maybe somebody else will fight this in the future =D), then you could change it to that:

        @EVAL $output = $modx->runSnippet('getResources',array('parents'=>'0','tpl'=>'@INLINE [[+pagetitle]]([[+id]])==[[~[[+id]]]]','outputSeparator'=>'||','sortby'=>'pagetitle','sortdir'=>'ASC','limit'=>'0','showUnpublished'=>'1','showHidden'=>'1','depth'=>'3')); return 'Resource waehlen==||' . $output;


        that is faaaar better than the native input type "resourceList"...don't know why there's no sorting implemented...that's essential in my opinion...

        What I also could also think of to improve this one would be a structuring of the select box, so that sub-resources would be indented and this time sorted by menuindex, so that (assuming that this is your resource tree sorting field) the select box is more or less an exact copy of the resource tree.

        Indenting (when not possible with spaces or tabs) could also be done like

        Top level resource
        - First sublevel resource
        -- Second sublevel resource
        
        // but it would be nicer to have it with tabs like
        
        Top level resource
            First sublevel resource
                Second sublevel resource
        


        but I really don't know how to approach this one, so I'm just thankful for what I have now with your code Bruno! Thanks again... (PS: Are you @modxpo? Should buy you some beers =D...) [ed. note: exside last edited this post 11 years, 6 months ago.]
          • 4172
          • 5,888 Posts
          this should be possible with wayfinder and special rowTpls.

          Another Solution could be three dynamic-dropdowns, my dddx, where you would have one listbox-tv for each level.
          The childs-listbox is dynamically filled with the childs of the selected parents from its parent-selectbox.
            -------------------------------

            you can buy me a beer, if you like MIGX

            http://webcmsolutions.de/migx.html

            Thanks!
            • 40045
            • 534 Posts
            The Wayfinder option sounds interesting (also the other one, but that seems way too complex...), just tried it bc I'm curious if it works...but, it didn't =)...

            first I tried the following (while hoping, that Wayfinder can parse the &xTpl properties directly = without giving it a chunk, like the nice @INLINE feature of getResources...)

            @EVAL $output = $modx->runSnippet('Wayfinder',array('contexts'=>'web','startId'=>'0','level'=>'0','ignoreHidden'=>'1','removeNewLines'=>'1','textOfLinks'=>'pagetitle','outerTpl'=>'[[+wf.wrapper]]','rowTpl'=>'||[[indent? &id=`[[+wf.docid]]` &indentstring=`  `]][[+wf.linktext]]([[+wf.docid]])==[[+wf.docid]][[+wf.wrapper]]','sortBy'=>'menuindex','sortOrder'=>'ASC'); return 'Ressource wählen==' . $output;
            

            but no output in the Select box (only the hardcoded String...but no $output added...like it's empty or not processed

            then I tried to pack the &xTpl property-contents in seperate chunks, to make it just as similar to a "normal" navigation wayfinder call

            @EVAL $output = $modx->runSnippet('Wayfinder',array('contexts'=>'web','startId'=>'0','level'=>'0','ignoreHidden'=>'1','removeNewLines'=>'1','textOfLinks'=>'pagetitle','outerTpl'=>'rsrcListTVouterTpl','rowTpl'=>'rsrcListTVrowTpl','sortBy'=>'menuindex','sortOrder'=>'ASC')); return 'Ressource wählen==' . $output;
            
            // while the content of the chunk rsrcListTVrowTpl is
            ||[[indent? &id=`[[+wf.docid]]` &indentstring=`  `]][[+wf.linktext]]([[+wf.docid]])==[[+wf.docid]][[+wf.wrapper]]
            
            // and the one of the chunk rsrcListTVouterTpl is just
            [[+wf.wrapper]]
            


            but that also did not give me any output, still empty select box like seen on the following screenshot...



            The "indent" snippet is based on Brunos code further down, way better than my initial idea which I edited out (so thanks again to him!!!)... the code for the snippet is the following:

            // snippet "indent"
            // @param id: the current resource id
            // @param indentstring: string which should be used for indenting according to the level in the document tree...defaults to a "-" per level
            $settings =& $scriptProperties;
            $parentids = $modx->getParentIds($id, 10, array('context' => 'web'));
            $indentstring = isset($settings['indentstring']) ? $settings['indentstring'] : '-';
            $output = '';
            
            $i=0;
            foreach($parentids as $parentid){
                if ($i>0){
                    $output .= $indentstring;
                }
                $i++;
            }
             
            return $output;
            


            Then (in my desperation) I added
            'debug'=>'1'
            to the call, but that just showed me the following in the select box (noting in error log or somewhere else...so that wasn't very helpful...on the other side that's definitely not what's wayfinder made for, so I cannot blame it to not be helpful in this situation =D):



            the "funny" thing about that is, that this happens in both cases (when the templates are given directly into the params or given by chunk)...so that doesn't seem to make a difference here...I tried the same in the (following) frontend experiment and there it failed miserably...so I conclude, that giving pure HTML to the &xTpl properties of Wayfinder doesn't work ie. no @INLINE capability. Possibly this is also the reason that no output is generated?? Maybe the chunks are not processed huh ? But if this is the case, why is there only one entry and the subentry chunk shown in the select list, shouldn't there be more because Wayfinder would fetch all resources, but could just not parse them right...I don't get it...


            After not being successful at all I tried to just make a normal Wayfinder call in the frontend of the site (like if I want to build a navigation):
            [[!Wayfinder? 
            	&startId=`0` 
            	&level=`0` 
            	&ignoreHidden=`1`
            	&removeNewLines=`1`
            	&outerTpl=`rsrcListTVouterTpl`  
            	&rowTpl=`rsrcListTVrowTpl` 
            	&textOfLinks=`pagetitle`
            	&sortBy=`menuindex`
            	&sortOrder=`ASC`
            ]]
            


            so that's exactly what I tried to do in the @EVAL code (same parameters) and on the frontend this seems to generate exactly what I need:

            ||News(1)==1||  A second level resource(52)==52||Another Resource(51)==51||ResourceX(53)==53||Another one(3)==3
            


            but in the backend it does not seem to do that^^...I don't see the reason why it's not giving me any output...so that's how far I came...any idea what I'm doing wrong? [ed. note: exside last edited this post 11 years, 6 months ago.]
              • 4172
              • 5,888 Posts
              try this:

              input-options:

              @EVAL $output=$modx->runSnippet('Wayfinder',array('contexts'=>'web','startId'=>'0','outerTpl'=>'wfListBoxOuter','rowTpl'=>'wfListBoxRow'));return 'Ressource wählen==||' . $output;
              


              wfListBoxOuter:
              [[+wf.wrapper]]


              wfListBoxRow:
              [[treelevel? &id=`[[+wf.docid]]`]][[+wf.pagetitle]]==[[+wf.id]]||[[+wf.wrapper]]
              


              snippet treelevel:
              $parentids = $modx->getParentIds($id, 10, array('context' => 'web'));
              
              $i=0;
              foreach($parentids as $parentid){
                  if ($i>0){
                      $output .= ' - ';
                  }
                  $i++;
              }
              
              return $output;
              
              [ed. note: Bruno17 last edited this post 11 years, 6 months ago.]
                -------------------------------

                you can buy me a beer, if you like MIGX

                http://webcmsolutions.de/migx.html

                Thanks!
                • 40045
                • 534 Posts
                So the only thing you changed is the setting
                'contexts'=>'web'


                in the Wayfinder call?

                I added that to my existing call, but that didn't change anything.

                And the treelevel snippet is just a better way / example to do what I tried with the
                &levelClass=`level`
                param, am I right? So instead of adding a lot of
                [[+wf.classnames:is=`level2`:then=`  `:else=``]]
                clutter, you just made a nice snippet that outputs the desired amount of indentation characters, right? That's great, thank you for that...

                But still got no output in the Select box =/, even with the contexts param in the call.


                PS: Edited my previous post to it's actual configuration (based on the code and hints in the last post from Bruno) [ed. note: exside last edited this post 11 years, 6 months ago.]
                  • 19328
                  • 433 Posts
                  Hi, I was trying the same thing and although I also can't get this to work, I did find that changing the chunk wfListBoxRow from
                  [[treelevel? &id=`[[+wf.docid]]`]][[+wf.pagetitle]]==[[+wf.id]]||[[+wf.wrapper]]

                  to
                  [[treelevel? &id=`[[+wf.docid]]`]][[+wf.pagetitle]]==[[+id]]||[[+wf.wrapper]]

                  makes the output correct, otherwise the id was not added as list value. I saw this when running the EVAL code from a snippet. The output looks very good when I run it on a page like that, and if I paste the output directly in the 'input options' field of the TV, it does work and the list looks good and is indented.

                  But I also can't get it to work with runSnippet unfortunately. @exside, did you ever get this to work?
                    • 40045
                    • 534 Posts
                    @michelle

                    nope, sadly not, would still love to have this or at least understand WHY it doesn't work^^...I'm guessing that executing Wayfinder from mgr context is a problem, but that's just a shot into the dark...maybe a try with another menu builder snippet like BasicNav (http://modx.com/extras/package/basicnav) would bring results... I've never tried bc as usual in modx, there're several ways to achieve a goal =)... but I would be very interested in 1. why it doesn't work with Wayfinder and 2. If there is another way to achieve the same...

                    and to your correction of the chunk code =)...that's not what I have...in my chunk there was always the placeholder
                    [[+wf.docid]]
                    set, not
                    [[+wf.id]]
                    (which doesn't output anything if you dont set the param &rowIdPrefix in the snippet call), and this outputs what I needed =D [ed. note: exside last edited this post 11 years, 5 months ago.]
                      • 19328
                      • 433 Posts
                      yeah I would like to know why as well.. did find other people who were trying to run getResources the same way and also couldn't get it to work. When I have the time I'll have a look at that snippet BasicNav, who knows!