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

    I was hoping someone could give me the one liner for returning the weblink value of a document instead of the "internal path". This will probably look stupid but I thought it would be something like

    $docid = '12';
    $url = $modx->getDocument($docid, 'weblink', 1);


    But this obviously doesn’t work. I can’t remember where but I remember seeing something about returning the weblink value instead of default behaviour.
      • 14412
      • 74 Posts
      Take a look at the makeURL function.
        Got Music? Try XSPFjukebox - Skinnable MODx Media Player
        • 10487 MODX Staff
        • 1,535 Posts
        Garry Nutting Reply #3, 19 years ago
        The weblink URL is just stored in the ’content’ field, there’s no special ’weblink’ field or anything. If you adjust your code above then that should work okay.
          Garry Nutting
          Senior Developer
          MODX, LLC

          Email: [email protected]
          Twitter: @garryn
          Web: modx.com
          • 14412
          • 74 Posts
          Oops, I forgot about weblinks and thought sal was asking for the way to return a doc’s URL from code. My bad!

          Guess you should do:

          $docid = ’12’;
          $url = $modx->getDocument($docid, ’content’, 1);
          $url = $url[’content’];

          BTW, $url = $modx->getPageInfo($docid,1, ’content’); will work too.

          garryn, which one is the lightest method? I assume it’s getPageInfo() because it queries the DB directly and doesn’t call getDocuments(), is this correct?
            Got Music? Try XSPFjukebox - Skinnable MODx Media Player