Issue Summary

I had a need to add a rel="nofollow" to some links from the DS username field. I was able to add a template_preprocess_field__ds() but could not modify the attributes passed to the link.

Proposed Resolution

Modify the inline template link() function to pass a link_attributes 3rd parameter. These attributes are empty by default but can be modified by preprocess functions.

CommentFileSizeAuthor
ds-link_attributes.patch721 bytesmalcolm_p

Comments

malcolm_p created an issue. See original summary.

vistree’s picture

Hi Malcolm,
this is exactly what I need - and your patch works great for me. Maybe helpful for others:

in your custom.theme add a preprocess-field function to add a new attribute + add the new link_attribute to field template

 function mytheme_preprocess_field__node__node_link(&$variables) {
  foreach($variables['items'] as $key => $item) {
    $nodeTitle = "test title for node link a href";
    $variables["items"][$key]["content"][0]["#context"]["link_attributes"]->setAttribute("title", $nodeTitle);
  }
}
vistree’s picture

unrelated comment - removed it!

  • swentel committed ddb499b on 8.x-3.x authored by malcolm_p
    Issue #2980842 by malcolm_p: Add Link Attributes to DS Field Inline...

  • swentel committed e428ed1 on 8.x-4.x authored by malcolm_p
    Issue #2980842 by malcolm_p: Add Link Attributes to DS Field Inline...
swentel’s picture

Status: Needs review » Fixed

Works well, committed and pushed thanks!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.