We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 36
    • 3 Posts
    I would like to make a plugin that load the content of a other page by giving the alias manualy.
    How can I override the alias?

    So when when I open index.php?q=page1/page2 --> he opens: index.php?q=page3/test


    Thanks!
      • 28042 ☆ A M B ☆
      • 24,524 Posts
      For Evo, OnWebPageInit is the first event that a plugin can use. The documentIdentifier has already been established; however the GET value for $_GET[’q’] is still available. You should be able to use that value (which will be the alias plus the system setting for prefix and suffix, usually .html) to determine which resource you want, then modify the $modx->documentIdentifier at that point. The parser will continue processing the resource you specify.

      Take a look at document.parser.class.inc.php around line 1137 to see how it determines which resource to process. It makes use of the documentListing array taken from the assets/cache/siteCache.idx.php file.
        Studying MODX in the desert - http://sottwell.com
        Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
        Join the Slack Community - http://modx.org
        • 36
        • 3 Posts
        Sottwell, your story is clear.
        But I can’t say $_GET[’q’] = ’page0/page1’;

        Could you give me an example of the code?
          • 28042 ☆ A M B ☆
          • 24,524 Posts
          No, you would have to have your own code in the plugin to reset the documentIdentifier. Possibly a PHP switch structure? I don’t know how many pages you would want to change. Or perhaps a sendRedirect would be more appropriate than changing the documentIdentifier?
            Studying MODX in the desert - http://sottwell.com
            Tips and Tricks from the MODX Forums and Slack Channels - http://modxcookbook.com
            Join the Slack Community - http://modx.org
            • 36
            • 3 Posts
            A other solution is to change the site_start by a plugin.
            But it doesn’t work.

            if($_SERVER['HTTP_HOST'] == 'www.domain.com'){
            $modx->config['site_start'] = 8;
            }
            


            Plugin system: OnWebPageInit.
            Is this possible, while it is in Revo not working?

            (Source: http://modxcms.com/forums/index.php/topic,1445.0.html)
              • 22303 MODX Staff
              • 10,725 Posts
              This is the purpose of SymLinks in Revo. I do not recommend overriding the alias via plugin or changing the site_start dynamically.