We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
  • Cool, great news! I have found one small problem that if you have downloaded it already is straightforward to fix. In the __getKeys() function in rating.class.php, look for this line:
    $this->_cookieDKey = & $this -_cookiePKey;

    And correct it to:
    $this->_cookieDKey = & $this->_cookiePKey;

    I’ll update the beta download package in a mo once I’ve had my very-needed coffee smiley


      Garry Nutting
      Senior Developer
      MODX, LLC

      Email: [email protected]
      Twitter: @garryn
      Web: modx.com
      • 10666
      • 68 Posts
      I changed that and have begun testing.



      Already experiencing some breakage sad.

      When using:
      [!star_rating? &docID=`[+id+]` &useCookie=`true` &cssFile=`assets/css/snippets/star-rating.css` !]

      ModX breaks,and I get this:
      « MODx Parse Error »
      MODx encountered the following error while attempting to parse the requested resource:
      « PHP Parse Error »
       
      PHP error debug
        Error: 	array_key_exists() [function.array-key-exists]: The second argument should be either an array or an object	 
        Error type/ Nr.: 	Warning - 2	 
        File: 	/var/www/modx/assets/snippets/star_rating/rating.class.php	 
        Line: 	297	 
        Line 297 source: 	if (array_key_exists($this->passedId, $cArray)) { 	 
       
      Parser timing
        MySQL: 	0.0112 s	(11 Requests)
        PHP: 	0.0882 s	 
        Total: 	0.0994 s	 


      However, it works fine without the $useCookie=`true` paramater.

      BUT,if I vote once on a useCookie page enabled,even if I modify the snippet’s call,I still get an error,no matter what.(Edit:Actually , if I delete some of the "starRating" cookies, the page loads fine again.)

      I’ve found some interesting things.
      First of all:
      Just reloading a page that I voted on before (and has multiple star-rating calls) I find that it resets the following cookie:
      name:cssStarRating13
      Content:novote
      [...]
      

      and some other details.As you’ve probably noticed ,13 is the pid from the previous vote. But: I voted ,got the error,changed the call and refreshed the page...

      Also,this cookie is constantly being set(without any voting!!):
      name:starRating
      content:a%3A1%3A%7Bi%3A13%3Ba%3A1%3A%7Bi%3A1%3Bs%3A1%3A%221%22%3B%7D%7D
      

      I have around 3 instances of them active , and they only differ by the time .

      Also,did I mention that if I get the nasty error page ,and just delete the cookies and refresh the error page,around 3-4 cookies of the last type appear (and their timestamp differs by 20-30 minutes each undecided ) and ofcourse , one of the starRating13 type smiley . [maybe something is left unset ?]

      Btw,I also have a LOT of session cookies(or whatever they are called):
      name:SN45561233b0676
      Content:56b457fba364e6e5f2e5fb3f6d8ab227
      [...] Some differ by path,some by nothing ( I have about 10 of these :| ).


      I’ll be doing some more testing tomorrow,and try to rephrase my explanations smiley.

      PS: Using Firefox 2.0,haven’t tested with anything else yet .
      • Okay, I’ll check it out - the only cookie that matters for the star rating v2 is the one called ’starRating’ - that is the new cookie format used in this version. It looks like something isn’t being retrieved from the cookie correctly - should be a simple fix. (The format looks weird because its a serialized array that PHP automatically url-encodes when saving it in the cookie)

        The cssStarRating13 cookie is the old format of how the star rating v1 stored cookie information so is probably there from a previous call. The ’SN ....’ cookies are the MODx cookies that are generated. None of these should be causing a problem.

        Oh, the joy of cookies ...
          Garry Nutting
          Senior Developer
          MODX, LLC

          Email: [email protected]
          Twitter: @garryn
          Web: modx.com
          • 10666
          • 68 Posts
          Quote from: garryn at Jan 15, 2007, 10:17 PM

          The cssStarRating13 cookie is the old format of how the star rating v1 stored cookie information so is probably there from a previous call. The ’SN ....’ cookies are the MODx cookies that are generated. None of these should be causing a problem.

          Oh, the joy of cookies ...

          Well, the odd thing with the cssStarRating13 cookie ... is that it is also regenerated with the other ones. :|
          There isn’t any code left in ModX from the 1.0 version that could generate that ,and even if I delete it (I’ve must of cleared the cookies 5-6 times by now),it still pops in after a page refresh smiley .
          • Okay, well I switched over testing environments to a MAMP setup and I can get the error now - seems to be a difference in how the cookie value is stored by PHP in the two environments. I need to iron out a few more little issues before I update the package that seem to be a knock on effect of accounting for the cookie changes.

            As soon as I’ve had chance to test it out on both my testing environments to make sure my changes work, I will post a new beta.

            (I also seem to get the multiple session cookie thing under MAMP as well, I think the two issues could be related so I’ll investigate that a bit further once I’ve got this star rating straightened out)
              Garry Nutting
              Senior Developer
              MODX, LLC

              Email: [email protected]
              Twitter: @garryn
              Web: modx.com
              • 10666
              • 68 Posts
              You mentioned you got that under MAMP , and I assume your other developing package was WAMP.
              I got it under LAMP (Linux AMP).

              Btw, in the archive with the snippet files you provide, there is a __MACOSX folder and some .DS_STORE files . I guess they are hidden in OSX , but I assume they are of no use to us (hope they don’t contain any sensitive information about your computer tongue ).
              • If you don’t already know about it Garry... look on version tracker for Clean Archiver.
                  Ryan Thrash, MODX Co-Founder
                  Follow me on Twitter at @rthrash or catch my occasional unofficial thoughts at thrash.me
                • Cheers Ryan, I’ll check it out - I’ve using BetterZip but seems it doesn’t avoid that annoying problem. grin

                  @Geo88: No, the files are nothing sensitive - and, yes, of no use whatsoever to you - they’re just files that Mac OS X uses to store information about the folder display options etc.

                  To answer your first question, I use MAMP and Entropy which are both Mac-based packages for testing along with Windows on a VM running XAMPP (and I have Suse10.1 on my other laptop which I use with LAMPP - the Linux version of XAMPP - for testing on that). tongue
                    Garry Nutting
                    Senior Developer
                    MODX, LLC

                    Email: [email protected]
                    Twitter: @garryn
                    Web: modx.com
                    • 16886
                    • 40 Posts
                    Don’t understand a small but important part in the readme-file:

                    New Installation
                    ----------------
                    1. Copy the star_rating folder from this package into assets/snippets. Done
                    2. Copy the contents of the star_rating.snippet.php into a new snippet in the MODx manager. Done
                    3. Create a new TV (use default TV options) and call it ’star_rating’ and assign it to the templates you use. ??? What kind of content has to be in the TV ?
                    3. Add a snippet call to the page you wish to add a vote (assuming you called the snippet ’starRating’): Done

                    The Star-Rating shown correct, but if i want to vote i get an error ( i know why, because i don’t use the TV but what content needs the TV? )

                    The Vote-Link for 5 Stars looks like this:
                    http://myhost.com/index.php?id=15&starvote=5&pid=15&tv=


                    I think i need a additional table in my database, or? and build a TV for this table, or? are there any examples?

                    thanks for any suggestion
                    greetings LeftHanded

                      I love ModX!
                    • Just create a TV, leave everything as the default options - no default content, no input value etc. - call it ’star_rating’. Check the tickboxes next to the templates you’re using and save the TV. (the value for the TV is all handled by the snippet itself)

                      It’s as simple as that, no hidden tricks or anything ... wink

                      And, if you’re using the beta, then please note that there are outstanding issues around the cookie and session implementation that I need to sort out (hopefully tomorrow if all goes to plan). Also, I’ll need to fix that problem above as it looks like an extra check needs to be added for cases like this.

                      For version 2, there will be a full install document with screenshots for each stage of the installation but I’m not gonna do that until I’m happy with the code itself.

                      Cheers,
                      Garry
                        Garry Nutting
                        Senior Developer
                        MODX, LLC

                        Email: [email protected]
                        Twitter: @garryn
                        Web: modx.com