0

I have been able to create a view of Users with format of Fields. I added user fields, and and found the UID field as well which I can use to link a field to the user's profile page.

However, I prefer to output views with the Content format and create a view mode for the view. For users, there is no Content format, and I assume the equivalent is User format.

However, when I created my display mode on the user profile and set it to a display suite layout, I found that there is no UID field (I did see Username, but that wont help). Does display suite not provide us this field?

1 Answer 1

1

Just as it does not provide a nid field for nodes, so it does not provide a uid field for users.

For format in your view you can also show 'Display Suite' which will open up more ds-goodness.

To show the uid you need to add a ds code field. it is best used with the token module installed as well.

enter image description here

Add the token [user:uid] as the field value.

enter image description here

The field will now become available for display suite to use. You could also use html in the code field, and for instance use the [user:uid] token to create a link, as in:

<a href="user/"[user:uid]">[user:name]</a>

Also note that you do not need to display the primary identifier of an entity (uid for users) in order to use it in views relationships. As users is the base table it will already be available.

2
  • Thanks for the detailed response. My only issue with it is that I found that when I set the format of the Field Code section to be 'Plain Text', the resulting value of the field was <p>[uid]</p>. I was able to fix this by setting the format to PHP. However, I would like to turn off the PHP filter, to prevent people from putting actual PHP code in the database. How could I recreate this field in code? Commented Jan 13, 2015 at 14:40
  • Use Full HTML as the text format (it does not work with plain text). Also check if you have you token installed. And the token is [user:uid], not [uid] Commented Jan 13, 2015 at 16:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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