revolution icon indicating copy to clipboard operation
revolution copied to clipboard

use_weblink_target breaks weblink preview if target is ID or link tag

Open matdave opened this issue 3 years ago • 7 comments

Bug report

Summary

When use_weblink_target is enabled, weblinks that use an ID or [[~ID]] format no longer work. Issue stems from the modContext class's makeUrl's handling of that variable.

Step to reproduce

Enable use_weblink_target in the system settings. Create a new Weblink with the ID of an existing resource. Save and Preview.

Observed behavior

The Weblink will take you to example.com/[[~ID]] or example.com/ID instead of the parsed link.

Expected behavior

It should work like standard weblinks and allow for the content to be parsed as a resource ID or dynamically created link.

Environment

Observed using 2.8.4 in MODX Cloud.

matdave avatar May 27 '22 21:05 matdave

I'm a bit confused as to what to actual behavior should be.

Set to true if you want to have MODX link tags and makeUrl() generate links as the target URL for WebLinks. Otherwise, the internal MODX URL will be generated by link tags and the makeUrl() method.

Link to the code: https://github.com/modxcms/revolution/blob/dc2a8570d1128914e5eb3980c2fcdd260bc96ad3/core/model/modx/modcontext.class.php#L259-L266

JoshuaLuckers avatar May 30 '22 11:05 JoshuaLuckers

The behavior is actually fine everywhere except when using "Preview" (aka "View") in the manager. The preview code is not processing tags if the target is specified as a MODX link tag. This used to work but changes were made to how the preview works in both 2.x and 3.x which has broken the behavior for this case.

opengeek avatar May 31 '22 17:05 opengeek

Did an integer ID ever work as a weblink target, though?

opengeek avatar May 31 '22 17:05 opengeek

Did an integer ID ever work as a weblink target, though?

Yes, for a regular weblink it checks if the content is an integer

matdave avatar May 31 '22 18:05 matdave

Whatever happened to the preview code, since this used to work just fine, will need to be restored to solve this.

opengeek avatar May 31 '22 19:05 opengeek

My guess is that we forgot to port PR #14954 from 2.x to 3.x

JoshuaLuckers avatar Jun 02 '22 10:06 JoshuaLuckers

It doesn't work in 2.x or 3.x.

opengeek avatar Jun 02 '22 16:06 opengeek