We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36582
    • 463 Posts
    I’m having a great time with Maxigallery - thank you.

    Is it possible (and if so how!) to get this working:

    Image Title="image_name.jpg" (but display without underscore and extension)

    and

    Image Description=email me about "image_name.jpg" (sends an email with subject of ’image name’)

    Sounds like a bit of a toughie to me but somehow I think it might be possible.
      Web site design in Nottingham UK by Chris Fickling http://www.chrisficklingdesign.co.uk
      • 7923
      • 4,213 Posts
      Of course it’s possible and quite easy. You need to do custom templates and replace the [+maxigallery.picture.title+] placeholders with [+maxigallery.picture.filename:mystrip+]

      Then do the PHx modifier mystrip what modifies the filename and returns it the way you want.. eg. "phx:mystrip" would be something like:

      <?php
      return str_replace('_', ' ', substr($output, 0, strrpos($output, '.')));
      ?>
      


      Then replace the [+maxigallery.picture.desc+] placeholders with

      <a href="mailto:[email protected]?subject=[+maxigallery.picture.filename:mystrip+]">E-Mail me about "[+maxigallery.picture.filename:mystrip+]"</a>
      


      And I would highly suggest to install some of the available e-mail address obfuscators from the resource repository, see: http://modxcms.com/resource-listing.html&tags=anti-spam and http://modxcms.com/resource-listing.html&tags=avoid+spamming


        "He can have a lollipop any time he wants to. That's what it means to be a programmer."
        • 36582
        • 463 Posts
        Many thanks - I’ll give it a go - I’m not too hot PHP but your instructions seem clear.

        Thanks again
          Web site design in Nottingham UK by Chris Fickling http://www.chrisficklingdesign.co.uk
          • 7923
          • 4,213 Posts
          I changed the strripos function to strrpos in the example, because the strripos is PHP 5 function and the case insensitiveness is not needed in this case..


            "He can have a lollipop any time he wants to. That's what it means to be a programmer."
            • 30821
            • 13 Posts
            hello,

            Im also interested in showing the filename. i dont understand the instructions below though... where do i find these placeholders and templates??

            thanks..

            You need to do custom templates and replace the [+maxigallery.picture.title+] placeholders with [+maxigallery.picture.filename:mystrip+]

            Then do the PHx modifier mystrip what modifies the filename and returns it the way you want.. eg. "phx:mystrip" would be something like...
              • 7923
              • 4,213 Posts
              The default templates are in /assets/snippets/maxigallery/templates.. See more information about the templates from MaxiGallery wiki page in MODx wiki.


                "He can have a lollipop any time he wants to. That's what it means to be a programmer."
                • 30821
                • 13 Posts
                i manage to mess around with the templates, but where do i write the code for "mystrip" below? now i am showing only filename and i would like to remove the .jpg at the end...

                <?php
                return str_replace(’_’, ’ ’, substr($output, 0, strrpos($output, ’.’)));
                ?>
                  • 28042 ☆ A M B ☆
                  • 24,524 Posts
                  The sleazy way would be to use rtrim on the whole thing:
                  return rtrim(str_replace('_', ' ', substr($output, 0, strrpos($output, '.'))), '.jpg');
                    Studying MODX in the desert - http://sottwell.com
                    Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
                    Join the Slack Community - http://modx.org
                    • 7923
                    • 4,213 Posts
                    Quote from: turtle_in_time at Feb 12, 2008, 06:32 PM

                    i manage to mess around with the templates, but where do i write the code for "mystrip" below? now i am showing only filename and i would like to remove the .jpg at the end...
                    Create a snippet called "phx:mystrip" and put the code there. Read more information about how PHx works from the modx wiki.



                      "He can have a lollipop any time he wants to. That's what it means to be a programmer."