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.
-
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...
I don’t really know anything about writing plugins so I’m going to go with the rewrite rule method. Thanks!