We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 8382
    • 253 Posts
    When you want to upload the pages exported by MODx to any other sites, the base tag in your template obstacles.
    Base tag is usually written like "<base href="http://your.site.com/modx/">". To upload to other site simply, you are navigated to original site, http://your.site.com/modx/...

    Following hack is to make the links to MODx documents relative path.
    Insert following lines between line 838 and 839 in document.parser.class.inc.php.
          $relPath="";
          if($this->config['friendly_alias_urls']==1 && $this->config['use_alias_path']==1) {
            $items = $this->aliasListing[$this->documentIdentifier];
            if ($items) {
              $relPath = strlen($items['path']) > 0 ? "../" : "" ;
              $relPath .= str_repeat("../", substr_count($items['path'], "/") );
            }
          }

    And, change line 839-841 in document.parser.class.inc.php.
    from
          foreach ( $this->aliasListing as $item ) {
            $aliases[$item['id']] = ( strlen( $item['path'] ) > 0 ? $item['path'] . '/' : '' ) . $item['alias'];
          }

    to
          foreach ( $this->aliasListing as $item ) {
            $aliases[$item['id']] = ( strlen( $item['path'] ) > 0 ? $relPath . $item['path'] . '/' : $relPath ) . $item['alias'];
          }

    that’s all.

    This hack has a weak point. When you access the pages in index.php?q=id, like a preview of the manager screen, it becomes strange. Please theach me a method to fix it.

    And, You must specify the resources except MODx documents like CSSs, Javascripts, images, with absolute path. ex. <img href="[(base_url)]images/logo.gif".
      • 22303 MODX Staff
      • 10,725 Posts
      Um, I’m confused, cause my templates are already using the base tag with [(site_url)] to achieve this. No hack required.