We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 17499 ☆ A M B ☆
    • 872 Posts
    Hello,

    MODx Revolution is about to land on us and there is one killer feature that’s missing: The ability to create custom URL with the API without using MODx document tree alone.

    Let me try to explain it further.

    On a topic concerning "blogging with MODx", Jason mentionned that if he had the time and the need to, he would use a container on the MODx tree, drop a snippet to load a custom blog engine using it’s own table and cache system outside of the document tree.

    Which is a pretty good idea and can be applied to many scenario like Ecommerce, Forums or whatever we can think of.

    I would like to take that road but not lose the ability to generate Rewrited URL in the process.

    If i have a document named "blog" with container checked. i would land on a page like this one: "http://localhost/blog/"

    Then if i select one of the blog entry i will most likely end with an url like that "http://localhost/blog/?myarticleid=2"

    This is where an api or a plugin can be useful, so that i can transform the previous url to : "http://localhost/blog/myentry-1.html" for example.

    The thing is to be able to catch $_GET[’articleid’] and do some magic with it to build a nice URL just like i can do it with makeUrl().

    That my question, is it possible with MODx Revolution ?
    If yes, what would be the best way, a built in API function or a plugin (I think that plugin is the way to go) ?
    Any example to achieve that behaviour without having to touch the htacess file (only with PHP) ?

    Stephane.
      • 21257 MODX Staff
      • 730 Posts
      I was just thinking about this this morning. It’s absolutely possible to accomplish this, and of course, there isn’t just one way to do it.
      I have a half-formed idea about how I’d like to approach it myself, and am hoping to get the time to work through it more.
      One of the simplest approaches for a resource endpoint like a blog engine is to have a plugin listen to the OnDocumentNotFound event, and process requests for URLs that it wants to. So in that sense, the ability to handle/create custom URLs is baked in, it just leaves the implementation to the developer instead of forcing an approach.
        Mike Schell
        Lead Developer, MODX Cloud
        Email: [email protected]
        GitHub: https://github.com/netProphET/
        Twitter: @mkschell
        • 17499 ☆ A M B ☆
        • 872 Posts
        That’s interesting.

        I’ve seen some code example here and there but didn’t test anything yet.

        Would it be possible that when you have worked on it, you share some examples on this forum ?
          • 28215
          • 4,149 Posts
          Checkout either the Archivist Extra, or the Redirector Extra.

          Archivist does custom URL handling. Redirector automatically handles redirects. Both use a plugin attached to the OnPageNotFound event.
            shaun mccormick | bigcommerce mgr of software engineering, former modx co-architect | github | splittingred.com
            • 17499 ☆ A M B ☆
            • 872 Posts
            Thanks Shaun!

            i’ll do that, like, now!! smiley