We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 5357
    • 30 Posts
    Is there a way to calculate either the first or last thumbnail in a row, upon which a class name like class="first", etc. can be added to the template?

    Reason is the current CSS applies any declared values to all thumbs and we require a custom class in order to override this (we have a set width and need to null any padding to either the first or last image).

    Thanks,
    Jim
      • 4172
      • 5,888 Posts
      you can use the placeholder [+maxigallery.picrownumber+] in your gallerypicturetpl for that together with the parameter &pics_per_row=`4`
        -------------------------------

        you can buy me a beer, if you like MIGX

        http://webcmsolutions.de/migx.html

        Thanks!
        • 5357
        • 30 Posts
        Ok, thanks, will have to update the snippet code we’re using as that doesn’t seem to be supported in our version.

        Jim
          • 7923
          • 4,213 Posts
          You can do odd / even / first / last with PHx like this

          Create a snippet named "phx:firstodd" with this content:

          $current = $output;
          $total = $options;
          if ($current == '1') {
             $output = 'first ';
          }
          if ($current == $total) {
             $output = 'last ';
          }
          if ($current & 1) {
             $output .= 'odd';
          } else {
             $output .= 'even';
          }
          return $output;
          


          Then in your galleryPictureTpl, use:

          class="[+maxigallery.picrownumber:firstodd=`[+maxigallery.config.pics_per_row+]`+]"

          That should create following classes to your thumbnails depending on their number in that row:

          class="first odd"
          class="odd"
          class="even"
          class="last odd/even" the odd/even on last one depends of course from the number of pics per row.


            "He can have a lollipop any time he wants to. That's what it means to be a programmer."
            • 5357
            • 30 Posts
            Thanks, is this snippet route a cleaner way or will the placeholder [+maxigallery.picrownumber+] still do the same thing?

            Jim
              • 7923
              • 4,213 Posts
              If you look closely, I have also used the [+maxigallery.picrownumber+] placeholder.

              What my example does is that it puts the odd/even/first/last classes automatic and you can use more general css. It doesn’t matter if some gallery has 2 pictures per row or 8 pictures per row. If you use the placeholder straight away, it just returns the number for the picture in that row. So if you had for example 6 pictures per row and wanted to style odd/even/first/last, in my example, you could use the classes:

              .first
              .last
              .odd
              .even

              in your css. But if you use the placeholder as is, like: class="picture[+maxigallery.picrownumber+]", you’d need to use:

              .picture1 <-is first and odd
              .picture2 <-even
              .picture3 <-odd
              .picture4 <-even
              .picture5 <-odd
              .picture6 <-is last and even

              And then if you create another gallery with just 3 pictures in the row, you cannot use the same css because you have "staticly" defined what number is the last one, so you would have to create other classes:

              .otherpicture1 <-is first and odd
              .otherpicture2 <-even
              .otherpicture3 <-is last and odd

              So by doing what’s in my example, you can use more general css classes and use the same classes for every number of pictures per row.


                "He can have a lollipop any time he wants to. That's what it means to be a programmer."
                • 5357
                • 30 Posts
                @Doze - all good and works like a dream, thanks!
                  • 25519
                  • 265 Posts
                  Hi
                  I’m trying to get this working but have no joy as yet so have a couple of q’s:

                  1: the placeholder:
                  class="[+maxigallery.picrownumber:firstodd=`[+maxigallery.config.pics_per_row+]`+]"

                  I’ve tried this in gallerypicturetpl.html in the <li> tag, and also to <img> within <li> (replacing class="thumbnail") but neither worked. Could someone let me know where it should go.

                  2: As there’s the phx:firstodd snippet involved, should I have PHx plugin active? For the record, so far I’ve tried with and without.

                  Thanks in advance

                    • 7923
                    • 4,213 Posts
                    You need v0.6 test version for this to work.


                      "He can have a lollipop any time he wants to. That's what it means to be a programmer."
                      • 25519
                      • 265 Posts
                      Thanks, got that, will dig ...