We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 12556
    • 103 Posts
    I’m creating a photo gallery with jQuery and SSP Director and I want users to be able to link to albums, which will be listed in a side bar, so when a user clicks on a link I want to go to a page like /photos/6 but I don’t want MODx to parse that, look for a document with that alias, and 404. Instead I want the 6 to be passed to the page as a query string variable and for a snippet I’m writing to display the content of the album ID that gets passed to it. Does MODx provide a way to do this or will I need to set up my own rewrite rules to do it? If the latter, how would I set up the rules in such a way that they won’t interfere with MODx’s friendly URLs but still pass the album ID as a query string variable? I could use AJAX to do it but I’d still need something like this for deep linking.
      • 22303 MODX Staff
      • 10,725 Posts
      Just write a plugin attached to the OnPageNotFound that parses the $_GET[’q’] however you want to handle the custom URL pattern you want for the various views from your snippet and have the plugin split it into $_GET[’q’] and whatever other GET parameter you want to use to do the work in your snippet (and redirect back to the page with the snippet). Or, write a custom rewrite rule to handle the pattern and split it the same way...
        • 12556
        • 103 Posts
        I don’t really know anything about writing plugins so I’m going to go with the rewrite rule method. Thanks!
          • 12556
          • 103 Posts
          Alright, I added this to my .htaccess file:
          RewriteRule ^photos/(.*)$ index.php?q=photos&albumID=$1 [L,QSA]

          I put it between the RewriteConds and the default friendly URLs rule, if that makes a difference.  It’s working fine and doing exactly what I want it to do but now for some reason the manager is screwed up.  I was logged in and the box where all the content in the manager is kept showing the 404 page no matter what I clicked on in the nav or document tree so I logged out and was going to try to log back in but /manager/ 404s too.  Everything on the actual site works fine though.  What up wit dat?
          Dave

          Edit:
          Nevermind. The site is messed up too. It doesn’t 404 but it looks like all the paths to my CSS files and images are messed up.