We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 16648
    • 4 Posts
    Hi!

    I’ve switched on the "friendly alias path" option and I’m trying to get retrieve contents of some document by its alias (I use getDocumentObject function). But this function contains following code -
           $sql= "SELECT sc.*
                  FROM $tblsc sc
                  LEFT JOIN $tbldg dg ON dg.document = sc.id
                  WHERE sc." . $method . " = '" . $identifier . "'
                  AND ($access) LIMIT 1;";
    

    and it cannot find complex aliases like ’one/two/three.html’ by scanning modx_site_content.alias field...
    I thought that ModX must have parser for such aliases to convert it to ids.

    What you can advice to me?

    PS I’m using ModX 0.9.6.1b.
      • 22303 MODX Staff
      • 10,725 Posts
      $modx->getDocumentObject is an internal function and not a public API; it’s used to prepare the requested document for rendering by the parser. There is currently not a function for looking up a document by the full alias path. This is something you would need to write a function to accomplish for now, perhaps using the $modx->documentListing array, which does have the full alias path (without the prefix/suffix applied) as the keys, or $modx->aliasListing which has the alias and path in an array indexed by document id.

      Upcoming releases will have a function for looking up the document id by the fully-qualified alias (including extensions for various content types).
        • 16648
        • 4 Posts
        Thank you! It really helps me =)