We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 30889
    • 29 Posts
    Hello,

    I would like to have the links inside a chunk/snippet work from a page outside of MODx. Is this possible?

    My results from the code below are

    http://localhost:8080/modxmg/[~11~] -> when using the chunk from a page outside of MODx

    http://localhost:8080/modxmg/index.php?id=11 -> when the chunk is called from within MODx

    $modx = new MODxAPI();
    // connect to db and load settings
    $modx->connect();
    $modx->getSettings();
    
    $menutop = $modx->getChunk('TopMenu');
    //$menutop = $modx->runSnippet('TopMenuToo');
    echo $menutop;
    


    I would like to be able to have a friendly URL so I don’t want to hard code the index.php?id=11 into my files outside of the MODx site.
      • 22303 MODX Staff
      • 10,725 Posts
      With the disclaimer that this method is private and will also be removed in future versions, you should be able to handle this for now by calling:
      $menutop = $modx->rewriteUrls($menutop);
      after getting the chunk. In the future the getChunk() function will process the content before returning.
        • 30889
        • 29 Posts
        Thankyou OpenGeek for a reply, that is exactly what I was after.

        I hope something similar will be available in future versions as I have found this to be quite useful.

          • 22303 MODX Staff
          • 10,725 Posts
          Quote from: Tybek at Feb 24, 2008, 09:05 PM

          I hope something similar will be available in future versions as I have found this to be quite useful.
          Absolutely there will be, and hopefully it will be even easier to use in more situations.