We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 17883
    • 1,039 Posts
    Hi g0mp,
    In the screencast you’re using @EVAL to run getResources or some sort of @SELECT?

    Actually I am running a SELECT for getting the values from a particular resource parent. I am using these ids for pushing them to getResources and display them in the selected order. I needed to modify getResources a bit for that.

    @lolotlm: I just commited a fix for the save button problem. I trigger the "click" event, so i f you click in the grid, the save button gets active.
      • 11076
      • 159 Posts
      hi, smiley

      I’ve made a TV named `Selection`:
      Input Type:          checkboxSortable
      Input Option Values: @SELECT `pagetitle`,`id` FROM `[[+PREFIX]]site_content` WHERE `parent` = 6 AND `published`= 1
      Output Type:         Delimiter
      Delimiter:           ,

      I’ve Assigned it to my template and it worked just fine far to this point.
      Managed to use ordering dragging & dropping and activating, getting the resources-id’s and outputting them separated by ’,’) e.g 2,3,5. so far so good.

      Then I’ve Made a new Snippet with your Custom Edition of getResources and Called it ’getResourcesMMDE’ (getResources Made My Day Edition).

      Then I’ve used it in a sample resource I’ve made with the call:
      [[getResourcesMMDE? &resources=`[[*Selection]]` &sortby=`resources` &tpl=`mySampleTPL` &sortdir=`ASC` &depth=`1` &limit=`10`
      &includeContent=`1` &tvPrefix=`` &includeTVs=`1` &showHidden=`1` &processTVs=`1`]]

      mySampleTPL Chunk contains:
      [[+pagetitle]] <br /> [[+content]] <br />

      and.. it doesn’t work. I don’t get any output.
      I’ve tried using direct input as `2,3,5` instead of using [[*Selection]] and still, nothing happens.
      I’ve tested it on Revo.2.0.64-pl2 if it has any connection to the issue.

      am i doing something wrong? or is it an issue of your custom edition of getResources?

      undecided
      _
      BTW ,I’ve checked your button trigger fix from github and it works fine now, thanks smiley.
        Michael Shraibman( gOmp)  | Freelance Design & Development | wink  impossible is nothing...
        • 17422
        • 225 Posts
        @MadeMyDay : i see, thanks for this update

        @gOmp : i create a snippet to view this TV

        [[affichageArtisteEnTournee? & tvname=`ArtistesTournee`]]


        affichageArtisteEnTournee :

        $tvname = $modx->getOption('tvname', $scriptProperties, '');
        $docid = $modx->getOption('docid', $scriptProperties, $modx->resource->get('id'));
        $tpl1="bloc_list_artiste";
        if ($tvname == '')
        {
            return;
        }
        
        $tv = $modx->getObject('modTemplateVar', array ('name'=>$tvname));
        $outputvalue = $tv->renderOutput($docid);
        $items =explode(",",$outputvalue);
        $chunk1 = $modx->getObject('modChunk', array ('name'=>$tpl1));
        $template1 = $chunk1->getContent();
        
            if (count($items) > 0)
            {
                foreach ($items as $item)
                {
                    $object=$modx->getObject('modResource',array('id'=>$item));
                    $pagetitle=$object->get('pagetitle');
                    $itemArr=array();
                    $itemArr['pagetitle']=$pagetitle;
                    $itemArr['id']=$item;
        
                                $chunk1 = $modx->newObject('modChunk');
                                $chunk1->setCacheable(false);
                                $output .= $chunk1->process($itemArr, $template1);
                }
            }
        return $output;​
        
        


        and my chunk bloc_list_artiste :
        <p>
          <a href="[[~[[+id]]]]" rel="lienInterne" title="[[+pagetitle]]"><img src="[[!premierePhotoArtiste? &id=`[[+id]]` &field=`Galerie`]]" alt="[[+pagetitle]]" /><span>[[+pagetitle]]</span></a>
        </p>
        


        the TV with :

        @EVAL return $modx->runSnippet('ListeArtistesPourTv',array("idRessource" =>"2"));



        Snippet ListeArtistesPourTv :

        $query = $modx->newQuery('modResource', array('parent' => $idRessource, 'deleted' => false, 'published' => true));
        $children = $modx->getCollection('modResource', $query);
        
        $resourceIds = "";
        $i=0;
        foreach ($children as $child) {
         if ($i!=0) {
          $resourceIds.="||";
         }
          $resourceIds .= $child->get('pagetitle');
          $resourceIds.="==";
          $resourceIds .= $child->get('id');
         $i++;
        }
         return $resourceIds;
        



        I hope it will help


        Laurent
          • 17883
          • 1,039 Posts
          @gOmp: This is definitely weird, perhaps something changed in the meanwhile. But I got it: Change these two lines:

          if ($sortby != 'resources') $criteria->sortby($sortby, $sortdir);


          in

          if ($sortby != '`modResource`.resources') $criteria->sortby($sortby, $sortdir);


          if(is_array($globalresources) && $sortby=='resources')


          in

          if(is_array($globalresources) && $sortby=='`modResource`.resources')


          then it should work.

          I have to admit that this is not a proper solution since the sortby parameter is reserved for columns to sort by. I will try to file feature request for getresources so Jason or Shaun can implement it in a more MODx-way ;-)

            • 11076
            • 159 Posts
            @lolotlm, I’ve started looking at your code and then i saw the update from MadeMyDay so i’ve tried it first, But thanks,i will try yours too, maybe it’s more suitable.

            with your suggestion iv’e tried [[affichageArtisteEnTournee? & tvname=`Selection`]] ,changed the $tpl1 to my chunk name which contains [[+id]] - [[+pagetitle]]
            and left my tv (`Selection`) with the @SELECT binding with a `,` delimiter instead of using the whole @EVAL method with an extra snippet for that purpose.
            it seems mine @SELECT and your @EVAL are doing the same thing, or am i wrong? (didn’t give it that much attention and i’m not that quite of programmer really)
            maybe i should of try your way all the way through, cause I’ve got an error after using just an half.

            @MadeMyDay, It works just as it should laugh haha.. thanks a lot.
            about the feature request, count me in, if you post a request share us the link.

            A minor thing: The checkboxSortable input remembering just the order of an active chosen items and those checked-one’s (chosen one’s) are showed up at the top of the list in the input-list while all the unActive(unchecked) items are unordered at the bottom (in fact you can’t order them cause it won’t remember and will order them by id at the bottom).

            Another thing is when deleting for good a resource that has been checked somewhere before, it still appears in the input as checked but the label of the checkbox is empty cause it remembering the selection of it, but that might be just an issue of how modx handles inputs rather than an `checkboxSortable` bug.
            i don’t know if i described it right, hope you understand and if not i’ll try to explain myself again.


            Thanks again , to you both smiley
              Michael Shraibman( gOmp)  | Freelance Design & Development | wink  impossible is nothing...
              • 17883
              • 1,039 Posts
              A minor thing: The checkboxSortable input remembering just the order of an active chosen items and those checked-one’s (chosen one’s) are showed up at the top of the list in the input-list while all the unActive(unchecked) items are unordered at the bottom (in fact you can’t order them cause it won’t remember and will order them by id at the bottom).

              There is nothing you can do, MODx only saves the checked values by design, so... nothing possible without huge efforts (we would have to rewrite the way the values get saved to the DB especially for that input filter like value1=checked||value2==unchecked||value3==unchecked||value4==checked and so on. Would be possible but the standard way of MODx to "read these values wouldn`t apply, so you cannot use these values from another "standard" Snippet like gR or whatever).

              Another thing is when deleting for good a resource that has been checked somewhere before, it still appears in the input as checked but the label of the checkbox is empty cause it remembering the selection of it, but that might be just an issue of how modx handles inputs rather than an `checkboxSortable` bug.

              Yes, the same problem. But I think this would also occur on usual checkbox filters. Problem here is rather that you changed/deleted the key/value-pairs and in the DB the values are saved only by their values.
                • 11076
                • 159 Posts
                You’re right,
                I Think that it would be much better if while rendering the tv input in the manager it would cross-check if the stored values are those who appears as part of your `Input Option Values` so if you change your input option values/or deleting a resource/chunk/whatever you don’t need to go and update the tv all across your site.
                I suppose it’s another feature request, right? wink
                  Michael Shraibman( gOmp)  | Freelance Design & Development | wink  impossible is nothing...
                  • 17883
                  • 1,039 Posts
                  I Think that it would be much better if while rendering the tv input in the manager it would cross-check if the stored values are those who appears as part of your `Input Option Values`

                  I think that would be possible (Bruno? smiley ).

                  so if you change your input option values/or deleting a resource/chunk/whatever you don’t need to go and update the tv all across your site.

                  Well, in our use case it would do something harmful because the resources just don`t exist, so getResources will not render them... but you are right, they have to be removed from the input list.
                    • 11076
                    • 159 Posts
                    laugh Bruno to the rescue..

                    Meanwhile i posted a new topic about that issue (`Tv’s Input Option Values Leftovers`):
                    http://modxcms.com/forums/index.php/topic,59700.0.html
                      Michael Shraibman( gOmp)  | Freelance Design & Development | wink  impossible is nothing...
                      • 5340
                      • 1,624 Posts
                      Quote from: Romain at Dec 15, 2010, 04:03 PM

                      Bruno’s fix + lexicon support added on my fork. I can request a pull if you want MadeMyDay. Gonna try to make a script to manualy package the stuff.
                      Once again, much thanks for your awesome work guys

                      Hi,

                      I tried your implementation but the language part is not working. The col headers are empty.
                      The other thing is that the save button is not activated when I check a box so basically there is no way to save unless you edit another field

                      Thanks