We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 24362
    • 11 Posts
    Within a weblink-resource the target-link in the content-field (*content) needs to be surrounded by modx-link-syntax:
    [[~333]]

    If there is only the id as numeral and friendly-url-setting is on I got 404-error - is it the expected behaviour?
    When dragging and dropping a resource into the content-field of a weblink-resource the id became a numeral without the link-syntax and so it produces the error.

    I wrote a little plugin that looks for numerals in the content-field of the currently edited weblink-resources and surround those with the link-syntax with the event onBeforDocFormSave. The change in the content-field you see not before reopen the resource but its done anyway.

    <?php
    $myClassKey = $resource->get('class_key');
    $myContent = $resource->get('content');
    if (($myClassKey == 'modWebLink') && (is_numeric($myContent))) {
        $resource->set('content','[[~'.$myContent.']]');
        $resource->save();
    }
    ?>


    Is there any other, better or modx-conformer way to do so?

    Thanks in advance!
    Rainer

    --
    using MODX Revolution 2.2.4-pl (advanced)
      MODX 2.2.6 (advanced), PHP 5.3, MySQL 5.5.27
      • 22303 MODX Staff
      • 10,725 Posts
      I actually think this is a bug, or at least an inconvenient oversight. IMO, if numeric, MODX should build the URL to redirect to automatically, otherwise attempt to send to the URL provided as-is.
        • 22303 MODX Staff
        • 10,725 Posts
        This is fixed for the upcoming 2.1.5-pl patch release. See https://github.com/modxcms/revolution/commit/bae49445471fed61e2d236f2e941cf83b6d79805 for commit details.
          • 27117
          • 28 Posts
          Do you mean 2.1.5-pl or 2.2.5-pl?

          I ran into the same problem as rai and I'm on 2.2.4. I just checked the code of my modweblink.class.php and there is still the old (wrong) code. I manually made the changes as described on github and now it works.
            Modx 2.1.3, PHP 5.2
            • 22303 MODX Staff
            • 10,725 Posts
            Quote from: shotup at Aug 17, 2012, 05:50 PM
            Do you mean 2.1.5-pl or 2.2.5-pl?
            Sorry, I meant 2.2.5-pl.