We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 34120
    • 236 Posts
    Hi there,
    I'm hoping someone can help me out with this, I'm looking to get friendly urls working with the Gallery component.

    My urls currently look like this:

    /portfolios/?galAlbum=fashion
    /portfolios/?galAlbum=events

    Ideally I'd like to get them like this:

    /portfolios/fashion/
    /portfolios/events/

    Also, I wondered if Gallery support for aliases would be a useful request? I'm currently pulling 'fashion' and 'events' from the album description.

    Any help much appreciated.
    Thanks



      • 37317
      • 77 Posts
      did you get this fixed?
      I also need the same solution.
      10x
        • 34120
        • 236 Posts
        Hi,
        No I didn't figure anything out but I'm working on a gallery right now and need to implement this. I'll post back here and let you know how I get on.
        • Don't think that's natively supported by Gallery. You should be able to manually make the links as you want them (for example with your name or description - I'd advice using the "urlencode" output filter to sanitize it for URLs), and use something like this to properly point it to the page:

              RewriteRule ^portfolios/([^/]+)/$ portfolios/?galAlbum=$1 [L,QSA]

          (untested, but did something similar for a different use case)
          Make sure you put that before the "friendly urls" part of the .htaccess file.
            Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

            Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
            • 34120
            • 236 Posts
            Thanks for the reply Mark. I'm struggling to get any of this working. My setup is a little different from my original post so I'll run through where I'm at now. I'm leaving out the urlencode bit for now.

            My URLs look like this:
            url.co.uk/clientarea/testsite/folios.html?galAlbum=2

            and I'm trying to get:
            url.co.uk/clientarea/testsite/folios/2/

            RewriteEngine On
            RewriteBase /clientarea/testsite/
            
            #This is what I'm trying (not both at the same time)
            RewriteRule ^folios/([^/]*)/$ /folios.html?galAlbum=$1 [L,QSA]
            
            RewriteRule ^folios/([^/]+)/$ folios.html?galAlbum=$1 [L,QSA]
            
            # Friendly URLs
            RewriteCond %{REQUEST_FILENAME} !-f
            RewriteCond %{REQUEST_FILENAME} !-d
            RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
            


            Neither of these seem to have any effect. I'm not too familiar with this sort of stuff so I've been working with this generator http://www.generateit.net/mod-rewrite/ but I'm out of ideas now.

            [ed. note: bobwal last edited this post 12 years, 4 months ago.]
            • Rewrite rules don't change your URLs - they only map a certain request to somewhere else.

              You'll need to create (hardcode) the links yourself in the Gallery template chunks.

              For example:

              <a href="/folios/[[+id]]/">[[+name]]</a>


              The rewrite stuff will then map the /folios/2/ to folios.html?galAlbum=2, providing the Gallery snippets with the data it needs to display what you requested.
                Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

                Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
                • 34120
                • 236 Posts
                Oh wow, I can't believe I've just spent so long stumped on that, I've done that bit before too. Face to palm required. Thanks Mark, I'll post the solution when I've got it fully working.

                  • 34120
                  • 236 Posts
                  All working now, thanks for the help Mark.

                  So using GalleryAlbums for my nav with galAlbumRowTp as the following:
                  <li[[+cls:notempty=` class="[[+cls]]"`]]><a href="folios/[[+name:urlencode]]/">[[+showName:notempty=`[[+name]]`]]</a></li>


                  Then in .htaccess placed before the friendly urls part:
                  RewriteRule ^folios/([^/]+)/$ folios.html?galAlbum=$1 [L,QSA]

                  Sweet
                  • Thanks for posting your solution!
                      Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

                      Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
                      • 37317
                      • 77 Posts
                      this is what i am using in my htaccess:

                      RewriteEngine On
                      RewriteBase /
                      RewriteCond %{REQUEST_FILENAME} !-f
                      RewriteCond %{REQUEST_FILENAME} !-d
                      #RewriteRule ^(.*)$ index.php?q=$1 [L,QSA]
                      RewriteRule ^portfolio/([^/]+)/$ index.php?p=$1 [L,QSA]
                      


                      which allows me to use the following output link:
                      http://www.mydomain.com/portfolio/conceptual/
                      where p= is conceptual.