We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 22840
    • 1,572 Posts
    Looks like I fixed it by doing the following:

    Change line 26 from :
    $rating = round($vals[0]/$vals[1], 2);

    To:
    $rating = (@round($vals[0]/$vals[1], 2));

    Only done a couple of tests but it seems ok, If there are any security issues for doing this can someone let me know rolleyes

    Cheers Google grin
    • Can you check that for the document you receive this error you do not have a 0 after :?
      Hmm, looks like a bug in the extender then wink

      Possible fix is:
      $rating = empty($vals[1]) ? 0 : round($vals[0]/$vals[1], 2);

      That’s untested but should fix the issue, otherwise I will test tomorrow ...
        Garry Nutting
        Senior Developer
        MODX, LLC

        Email: [email protected]
        Twitter: @garryn
        Web: modx.com
        • 22840
        • 1,572 Posts
        Quote from: garryn at Sep 09, 2009, 11:23 PM

        Can you check that for the document you receive this error you do not have a 0 after :?
        Hmm, looks like a bug in the extender then wink

        Possible fix is:
        $rating = empty($vals[1]) ? 0 : round($vals[0]/$vals[1], 2);

        That’s untested but should fix the issue, otherwise I will test tomorrow ...

        Yep that works,

        Just out of interest whats the difference between my fix and yours as mine uses less code ( learning so need things explaining grin )

        Thanks for the quick fix

        Paul
          • 5340
          • 1,624 Posts
          If I remember well you are just suppressing the output of an error not fixing the error.
            • 22840
            • 1,572 Posts
            Ahh right, so the "@" sign just says forget any errors and continue running the script ??

            Will remember not to use that again then shocked

            Thanks for explaining

            Paul
              • 22840
              • 1,572 Posts
              Hi Again,

              Right I was using &extenders=`star_rating` in my ditto call to show the star rating for documents listed from the call, however adding this seems to stop the sortBy in the call and I have no way of sorting by page title ( had to remove &extenders=`star_rating` to be able to sort )

              Is there a way to be able to sort in ditto and still have the &extenders=`star_rating` call.

              Thanks
              • Right I was using &extenders=`star_rating` in my ditto call to show the star rating for documents listed from the call, however adding this seems to stop the sortBy in the call and I have no way of sorting by page title ( had to remove &extenders=`star_rating` to be able to sort )
                Well, the star_rating extender overrides the sorting to sort by the star rating average for each document. Do you mean that you want to sort by star_rating, and then by pagetitle? If you want to only sort by pagetitle, then I’m not sure why you want to use the extender in the first place undecided
                  Garry Nutting
                  Senior Developer
                  MODX, LLC

                  Email: [email protected]
                  Twitter: @garryn
                  Web: modx.com
                  • 22840
                  • 1,572 Posts
                  I want to use it as it outputs the star rating into my ditto call for each page.

                  Example:

                  I have a page that is displaying a list of articles that are rated using the title, short description and star rating score ( IE: 3.8 stars out of 5 ), then you can click throught to each article and are able to read the full article and rate it.

                  Does that make sence ??

                  I only want to be able to sort by page title as I want them alphabeticley, is there another way for me to pull the star rating into the ditto call so that it displays in the output ??

                  Cheers
                  • OK, this should work ... comment out the following lines in the extender file:
                    $ditto->advSort = true;
                    $ditto->addField('star_rating', '*');
                    $orderBy['custom'][] = array('sortBy','sortByStarRating');


                    This should stop it sorting by the star_rating but will still allow the star_rating placeholder to be set.
                      Garry Nutting
                      Senior Developer
                      MODX, LLC

                      Email: [email protected]
                      Twitter: @garryn
                      Web: modx.com
                      • 22840
                      • 1,572 Posts
                      Garry your a star thankyou,

                      Commenting out all 3 lines didn’t actually work but just commenting out the last did it,

                      thanks allot

                      Paul