We launched new forums in March 2019—join us there. In a hurry for help with your website? Get Help Now!
    • 10525
    • 247 Posts
    I wanted to allow members of one user group to be able to set Resource Type, but hide the Link Attributes field and set all Weblink Resources to open in a new window/tab by default.

    So, I created a Customisation Profile for that user group, set the Link Attributes (link_attributes) default value to target="_blank", and then made it hidden, thinking that this field was used only for resources with Weblink Resources.

    This turned out to be wrong, as from then on, every Document Resource edited and saved had target="_blank" included in its menu link. New tabs galore...

    I fixed this by emptying the modx_site_content.link_attributes column in the database.

    Then I re-added target="_blank" into the Link Attributes field for two Weblink Resources. But this didn't work. I discovered that I didn't have [[wf.attributes]] in my Wayfinder rowTpl. So how had all the target="_blank" link_attributes got into my menu links?..

    The docs for Resource Fields (here https://rtfm.modx.com/revolution/2.x/making-sites-with-modx/structuring-your-site/resources) say:
    link_attributes - Used with menu building snippets to add attributes to links, etc. Can be repurposed for other needs.

    I can't see a mention anywhere of any automated inclusion of resource attributes in MODX-generated URLs, but is this what is happening?

    Is there any mechanism in MODX which uses resource attributes other than as described in the above docs page?
      • 30585
      • 833 Posts
      This turned out to be wrong, as from then on, every Document Resource edited and saved had target="_blank" included in its menu link.

      To restrict the "target="_blank" rule to Weblinks only, set the value of Constraint Field to class_key and the constraint to modWebLink. Otherwise, the rule affects all documents that use the same template as your weblink resources.

      Hope this helps.
        A MODx Fanatic
        • 10525
        • 247 Posts
        Thanks treigh, I'll try that.

        Do you have any idea how the target attribute was getting onto my menu links without the [[wf.attributes]] placeholder?
          • 30585
          • 833 Posts
          I'm not quite sure as I never use that field, but link_attributes settings are independent of Wayfinder. It's just like all other resource fields.
            A MODx Fanatic