We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 4172
    • 5,888 Posts
    joins are not added to the childresources-getlist-processor, but thats no problem. I will do that later today.
    Have just to copy/paste some lines of code from the default-getlist-processor.

    Seems also you will need to do some calculation before sending the stars to the grid

    vote_total/vote_count

    this could be done server-site by a custom-processor, which is also possible to have in MIGXdb or client-side by a custom-renderer.

    Since you want to see stars in the grid, you will need a custom-renderer, to show them.
    So I would choose the custom-renderer-solution in that case.

    is there a xpdo-schema for that star-rating, could you post it? [ed. note: Bruno17 last edited this post 14 years, 2 months ago.]
      -------------------------------

      you can buy me a beer, if you like MIGX

      http://webcmsolutions.de/migx.html

      Thanks!
      • 19328
      • 433 Posts
      This is the addon I used: http://modx.com/extras/package/starrating

      I did find attached file (starrating.class.php) in core/components/star_rating/model/star_rating, is this what you're after?
        • 4172
        • 5,888 Posts
        ok, what you will need to get the stars in the grid is:

        change the file /core/components/migx/processors/mgr/childresources/getlist.php
        to the latest on github:

        https://raw.github.com/Bruno17/MIGX/b74d9929dd625949a8eaed2901a165035644b614/core/components/migx/processors/mgr/childresources/getlist.php

        create a new folder in your core-path where you store some new configurations:

        /core/components/michelle/migxconfigs/grid/

        create two new files:
        your own config-file
        /core/components/michelle/migxconfigs/childstutorial.config.inc.php

        <?php
        
        $this->customconfigs['includeTVs'] = 1;
        $this->customconfigs['includeTVList'] = 'price,images,categories';
        
        
        $packageName = 'star_rating';
        
        $packagepath = $this->modx->getOption('core_path') . 'components/' . $packageName . '/';
        $modelpath = $packagepath . 'model/';
        $this->modx->addPackage($packageName, $modelpath);
        


        an additional renderer for your grid
        /core/components/michelle/migxconfigs/grid/grid.config.inc.php

        <?php
        
        $img = '<img src="{0}" alt="{1}" title="{2}">';
        $renderer['this.renderStars'] = "
        renderStars : function(val, md, rec, row, col, s) {
            var value = 0;
            if (val && rec.data.rating_vote_count){
                value = Math.round(val/rec.data.rating_vote_count);
            }
            if (value == 0){
                return;
            }
            var renderImage = '/assets/components/star_rating/style/images/stars/stars_'+value+'.png';
            var altText = 'star_'+value;
            return String.format('{$img}', renderImage, altText, altText);
        }
        ";
        


        you will need some images for this part:
        /assets/components/star_rating/style/images/stars/stars_'+value+'.png';

        now when you go the the MIGX-configurator and open your childstutorial-config for editing
        go to TAB MIGXdb-Settings and put in this values

        packageName: michelle (this is that MIGX can find your own configs)

        Joins:
        [{"alias":"rating","classname":"starRating","on":"star_id=modResource.id AND group_id=2"}]
        

        add the correct group_id to this json!

        save that with 'Done'

        open this configuration again and
        go to TAB columns

        and add a two new columns:

        Header: Stars
        field: rating_vote_total
        width: 20
        renderer: this.renderStars (you should see this renderer in the dropdown, if you did all correct)

        and this unvisible column:
        field: rating_vote_count
        show in grid: no

        save all that.

        now you should see the new grid-column with an alt-text or your star-images











          -------------------------------

          you can buy me a beer, if you like MIGX

          http://webcmsolutions.de/migx.html

          Thanks!
          • 19328
          • 433 Posts
          Finally the forums work again (yes!) and I can reply.
          It works! Thank you Bruno, if you send me your Paypal I'll buy you a beer!

          At first I had some problems, but then I added my custom db prefix to
          core/components/michelle/migxconfigs/childstutorial.config.inc.php
          like this:
          $prefix = $this->customconfigs['prefix'];

          and changed this line:
          $this->modx->addPackage($packageName, $modelpath);

          to
          $this->modx->addPackage($packageName, $modelpath, $prefix);


          And it worked.

          Now I'm trying to add Quip to the mix.

          So far I've managed to show the name of a commenter in the childstutorial grid! (not very useful yet, but for me it's quite an accomplishment ;-)

          First I added the package by adding the following code to my custom config file:

          //quip
          $packageName2 = 'quip';
          $packagepath2 = $this->modx->getOption('core_path') . 'components/' . $packageName2 . '/';
          $modelpath2 = $packagepath2 . 'model/';
          $this->modx->addPackage($packageName2, $modelpath2, $prefix);


          Then I altered the joins code for my childstutorial MIGX configuration to the following and this seems to work:
          [{"alias":"rating","classname":"starRating","on":"star_id=modResource.id AND group_id=1"},
          {"alias":"comments","classname":"quipComment","on":"resource=modResource.id"}]


          Then in the Columns tab I added this:
          Header: Quip comments
          field: comments_name
          show in grid: yes

          And voila, the name of (I guess the last comment for a particular resource) shows in the grid of childstutorial! So cool laugh. Don't know if I did this the correct way so far.

          I want to do the following now:
          1) show the total amount of comments for a resource in the main childstutorial grid. I think the rows in the table for a particular resource ID should be counted, because in the modxs_quip_comments table there can be several entries for one resource. The resource ID is placed in the column 'resource'. Should I do this with a renderer or another way?

          2) For each resource, when clicked on the 'edit' button, I want to show a tab called 'Comments'. Therefore I added a formtab 'Comments' on the childstutorial configuration (under Formtabs).
          I thought I would have to create another migx configuration for the comments. This is where I get stuck, because how can I make sure that only the comments for a particular resource will be shown here? Basically I want the same configuration as is used for the Articles component, where you can update, approve, disapprove and delete comments. Do you think there is a way I can copy the configuration from the Articles component and use it for my own MIGXdb-tv?
          Is the setup like it's done in Articles possible with MIGXdb anyway?
            • 36624
            • 535 Posts
            Just to say thanx to bruno for this tutorial !!!! In a lot of project i have many resource in the tree.. but since now i wasn't able to use MIGx this way !!!! THX THX THX !!
              CTRL+SHIFT+U - Clear Cache
              CTRL+SHIFT+H - Hiding Heft Panel
              CTRL+SHIFT+N - Fast Create Resource
              CTRL+ALT+P - Preview Recource (in edit resorce window)
              CTRL+ALT+S - Save
              • 37111 ☆ A M B ☆
              • 31 Posts
              Hey Bruno, frist of all thank you very very much for your totally awesome MIGX(db)!

              Is there a possibility to add a "View Resource"-Button in a migxdb-TV, which organizes (hidden) child resources?

              I've attached an image as example...

              Thanks again and nice weekend smiley
              Jens
                • 4172
                • 5,888 Posts
                should be possible with a custom - gridfunction and the new iframe-functionality.
                will try it out and post back how to make it done these days.
                  -------------------------------

                  you can buy me a beer, if you like MIGX

                  http://webcmsolutions.de/migx.html

                  Thanks!
                  • 37111 ☆ A M B ☆
                  • 31 Posts
                  Awesome smiley Thank you! smiley Nice weekend ;-)
                    • 37111 ☆ A M B ☆
                    • 31 Posts
                    PS: For me, it would be absolutely enough, if I can click on that Button and it opens a new Browser-Tab with the edited Site. Something like the "Show"-Button (in the "Save/Duplicate/Delete/Show/Close/Help!"-Bar right on top) in the MODx Backend, where you easily can open the page you are editing at the moment.
                      • 20215
                      • 144 Posts
                      Thanks Bruno for your great work!

                      I followed your tutorial http://rtfm.modx.com/display/ADDON/MIGXdb.Manage+Child-Resources+in+a+grid-TV+with+help+of+MIGXdb, and I have a little problem viewing the content formtab, when I insert/edit a resource, from MIGXdb TV, and select the tab content the window scrolls down hiding tabs with the scrollbar locked preventing switching to other tabs!

                      modx revo 2.2.4 pl
                      migx 2.3.2
                      Browser Chrome
                      richtext TinyMCE 4.3.3
                        ----------------------------------
                        canale irc Italiano #modx server: tophost.azzurra.org