We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 1511
    • 144 Posts
    I have friendly alias, friendly path and similar stuff all enabled. I use MODx 0.9.5 rev. 2106.

    friendly_urls 1
    friendly_url_prefix
    friendly_url_suffix .html
    friendly_alias_urls 1
    use_alias_path 1

    When I create a document somewhere in the virtual friendly path tree and try to generate an URL with makeUrl($id, $alias, ’’, ’full’), the URL returned is only http://www.domain.com/$alias.html instead of http://www.domain.com/path/to/my/page/$alias.html.

    Am I missing something?

    In this case I’d rather have a ’index.php?id=’ . $id . $args; result.

    What is $virtualdir variable doing in the makeUrl function code?
    TIA
      • 22303 MODX Staff
      • 10,725 Posts
      Don’t pass the alias -- this will override the alias specified in the system. Pass an empty string as the second parameter.
        • 27376
        • 576 Posts
        If you pass just the [tt]$id[/tt] parameter to [tt]makeUrl()[/tt] it will work fine.
          • 1511
          • 144 Posts
          Sorry to report but it wouldn’t work. What am I missing?

          I’m using NewsPublisherTagging snippet (same as NewsPublisher with added functionality for tags) to add documents and I figured out it didn’t clear the cache when I added a post (missing parameter), so after adding a document and listing it with Ditto, the link was www.domain.com/103.html (if the documents id was 103). I had to open the document in manager and resave it.
          When I added the clearcache parameter, the link for new documents was immediately the right one (www.domain.com/my/path/to/page/alias.html)

          Now, when I use the code from NewsPublisherTagging
                      if($clearcache==1){
                          include_once $modx->config['base_path']."manager/processors/cache_sync.class.processor.php";
                          $sync = new synccache();
                          $sync->setCachepath("assets/cache/");
                          $sync->setReport(false);
                          $sync->emptyCache(); // first empty the cache       
                      }
          
                      // get redirect/post id
                      $redirectid = $modx->db->getValue('SELECT id as \'redirectid\' FROM '.$modx->getFullTableName('site_content').' WHERE createdon=\''.$createdon.'\'');
                      $postid = isset($postid) ? $postid:$redirectid;
          
                      // redirect to post id
                      $modx->sendRedirect( $modx->makeUrl($postid, '', ''));
          
          it still doesn’t work.

          If I clear the cache and remove the alias parameter (as shown above), the redirect is still to the www.domain.com/id.html

          If anybody wants the link and un/pwd to the site, please, write me PM.
          At this moment I’m using
          $modx->sendRedirect($modx->config[site_url].'index.php?id='.$postid);
          to get the things right.
            • 27889
            • 415 Posts
            Hum I have the same problem, makeurl strip the parent folder of my created document.

            Someone have a solution ? or an info ? Perhaps a better way to reload the cache and fill the aliasListing array ?

            Edit: after some investigations, I think the problem is in the /manager/processors/cache_sync.class.processor.php arround line 100.

            Continuing proofer...
              MODx Sites & Prestations: http://dp-site.fr [Last MODx Site]
              MODx Repository: [HOME] [MetaTagsExtra] / Current Dev: [xFDM]
              • 22303 MODX Staff
              • 10,725 Posts
              The problem here is that until this request is completed, the new page will not be available in the current requests aliasListing because the cachesync processor simply writes the file out, but does not update it into the current request scope. The next request would be able to see the document.
                • 27889
                • 415 Posts
                Thank you for the info OpenGeek,
                a thing I don’t understand, you talk about a request, but which ?
                What I’m trying to do:
                - I insert a new doc in the db with a query
                - I make a flushcache with:
                <?php 
                                include_once $modx->config['base_path']."manager/processors/cache_sync.class.processor.php";
                                $sync = new synccache();
                                $sync->setCachepath("assets/cache/");
                                $sync->setReport(false);
                                $sync->emptyCache(); // first empty the cache  
                ?>

                - and after I call makeurl with the new ID inserted.
                ...until this request is completed,...The next request would be able to see the document.
                So I try two flushcache and a wait after them but with no chance.
                Is there a way to made a "new request for aliasListing" to have the correct url or must I build the url myself ?

                Thanks.
                  MODx Sites & Prestations: http://dp-site.fr [Last MODx Site]
                  MODx Repository: [HOME] [MetaTagsExtra] / Current Dev: [xFDM]
                  • 22303 MODX Staff
                  • 10,725 Posts
                  What I mean is that when posting the new page and refreshing the cache, the aliasListing in the physical siteCache file is updated, but in the scope of the current request (the same request where you posted the page and refreshed the cache) the old aliasListing is still in memory. It is not updated by the call to refresh the cache. It would be best to have a landing page to send to, along with the new ID as a parameter, that could then do a $modx->sendRedirect($modx->makeUrl($newpageid)) to the new page. This way, the refreshed siteCache is available on the landing page to properly build the URL.
                    • 27889
                    • 415 Posts
                    I’ll do that, thanks you for all these greats infos and your patience Jason
                      MODx Sites & Prestations: http://dp-site.fr [Last MODx Site]
                      MODx Repository: [HOME] [MetaTagsExtra] / Current Dev: [xFDM]