Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By Amjad_dokhan on
Dear everyone,
I have a title field in Views on which "link to content" is enabled, but now the title style is taking the default theme style for all links. I did append a div tag on the .tpl file but that didn't work. When I check the link in inspector it shows like this:
<div id="custom-id">
<a href="/node/16">Title</a>
</div>
Obviously I have to insert an ID in that href tag, but how. I've tried different things but Views does not have an option ffor adding id tag there. Any idea anyone ? Thanks in advance.
Comments
~
You can modify the tpl file or you can just go to Rewrite results in your field settings, enable Rewrite the output of this field and add your html around the field token.
It worked
Thanks nicoz. I followed your advice then I went on learning how to rewrite fields. I rewrote the title and the link and it works very nicely. Thanks alot
ID Reference
Amjad or Nicoz, can you explain how you referenced the content ID in your hyperlink? I am trying to reference content (node) id in a view, in order to construct a hyperlink, and coming up blank.