We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 17304 ☆ A M B ☆
    • 13 Posts
    1. Why is
    [[*class_key]]
    of SymLink documents = modDocument? Shouldn’t it be modSymLink?
    I put the above code in my template and point my page to a modSymLink page, and still get modDocument...

    2. Is there a way to get the actual id of the page a SymLink points to?
    i.e. if modSymLink id=22 points to modDocument id=10, is there a way for me to extract that ’10’ somehow in my template as an integer? I need it...

    Thanks
      • 18373 ☆ A M B ☆
      • 3,141 Posts
      1. You’re already getting the details for the resource it’s linked to, which in this case is the document.

      2. Try using a snippet to fetch the content field. Not sure, but might just work.
        Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

        Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.
        • 17304 ☆ A M B ☆
        • 13 Posts
        Thank you Mark...

        In my perception, when the URL shows:

        http://mysite.com/index?id=22

        then a class_key placed in that page’s template should give the class of document id=22. But that’s more of a design decision than a right/wrong issue, so...

        I solved both the above questions by writing a silly little snippet, e.g. getDocumentField:

        $id= isset($id) && intval($id) ? intval($id) : $modx->resource->get(’id’);
        $field = isset($field) ? $field : ’id’;

        $thisDocument=$modx->getDocument($id);
        return $thisDocument[$field];

        I then get what I need by
        [[!getDocumentField? &field=`class_key`]]
        [[!getDocumentField? &field=`content`]]

          • 18373 ☆ A M B ☆
          • 3,141 Posts
          I think it was designed in the way it is now to allow you to use snippets like getResources without having to worry about getting the right content there, instead of merely the id of the resource it’s being linked to. Else you would need snippets to retrieve the actual content, if you understand what I mean.
            Mark Hamstra • Developer spending his days working on Premium Extras and a MODX Site Dashboard with the ability to remotely upgrade MODX and extras to make the MODX world a little better.

            Tweet me @mark_hamstra, check my infrequent blog at markhamstra.com, my slightly more frequent ramblings at MODX.today or see code at Github.