2

Update#2

Actual user name is superuser but with kint, its still reading the admin id and displayname. This also happens to the URL, its reading the admin's profile link profile/1

enter image description here

I tried to dig into {{ content }} but cannot find tag with value superuser.


Update:

I noticed that in my twig template, {{ content.user_id }} would link into user's profile page(user/1), so the main question I think is what is the correct profile id of user in twig. I tried using content.profile_id but doesn't work.


I have this simple site that a user can post a simple content in the site. I also have a custom Profile type enabled from Profile module. I noticed that when I click on the photo, it is directed to the profile page profile/1(which is my expected result) but when the author name is clicked, it is directed into the user's profile page user/1. How can I change the author's name link to be directed into profile pageprofile/1?

enter image description here

2

You can use the example from Twig Functions:

{# Link to user entity page. #}
<a href="{{ path('entity.user.canonical', {'user': user.id}) }}">{{ 'View user profile'|t }}</a>

and modify the route to point the link to the profile page:

{# Link to user profile page. #}
<a href="{{ path('entity.profile.canonical', {'profile': user.id}) }}">{{ 'View user profile'|t }}</a>
  • Thank you so much for your reply. I use the below line and seems to be working. The link is directed into the profile's page however, the text displayed in the author's name is View user profile'. – John Rey Tanquinco Jul 27 '18 at 7:58
  • 1
    You can replace the text from the example with {{ user.displayname }} – 4k4 Jul 27 '18 at 8:16
  • Encounter another issue when using {{ user.displayname }}, it display only the admin Name and not the others. I also tried your answer in drupal.stackexchange.com/a/196637/70281 using author_name but giving me null value in kint(). Ill be sending the kint result in the issue above as reference. – John Rey Tanquinco Jul 27 '18 at 13:35
  • The linked answer is for a node template and only there author_name is available. – 4k4 Jul 27 '18 at 16:26
  • so any idea how can to access profile name/id of the author who posted the content? – John Rey Tanquinco Jul 28 '18 at 1:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.