Under the manage display for the user profile /admin/config/people/accounts/display, I have 4 view modes as below:

  • Default
  • Profile (Machine name: user.profile)
  • Company (Machine name: user.company)
  • Activities (Machine name: user.activities)

and under each view mode, I have a set of fields.

I also have a menu with below items:

  • Profile
  • Company
  • Activities

Now, I need when a user click on the menu item (Profile), to redirect him to the view mode: Profile and so on for other menu items.

So basically, the link for the menu item should be something like:


I was thinking something easy like:

/user/1#profile will direct the user of uid=1 to the view mode: Profile of his profile page.

/user/1#company will direct the user of uid=1 to the view mode: Company of his profile page.

/user/1#activities will direct the user of uid=1 to the view mode: Activities of his profile page.

How to switch between view modes using the url only ?

is that doable!? if no, any alternative way ?

UPDATE #1 (My requirement)

Say on the user profile page, I have the below fields (as an example):

  • field_1
  • field_2
  • field_3
  • field_4
  • field_5
  • field_6
  • field_7
  • field_8
  • field_9
  • field_10
  • field_11
  • field_12

And a simple menu with below items:

  • Profile
  • Company
  • Activities

I want when a logged in user click on the menu item:

  • Profile (to display for him only field_1 -> field_4)
  • Company (to display for him only field_5 -> field_8)
  • Activities (to display for him only field_9 -> field_12)

How can I do that ? (my javascript knowledge is very very limited)

  • 1
    You'd have to do it with javascript - the fragment (#) is a client-side feature, it doesn't get sent to the server – Clive Apr 12 '19 at 14:18
  • Isn't necessary for me to use (#), but switching between view modes from the URL is necessary! Can you please provide a detailed answer on how to achieve it with javascript thank you – Elie Masaad Apr 12 '19 at 14:42
  • 1
    Sorry but no, broad tutorials like that really don't belong here – Clive Apr 12 '19 at 14:55
  • 1
    There is a module that does this but I don’t know the name offhand. – Kevin Apr 13 '19 at 5:03

I think this is what you are looking for.


It will create viewable routes for view modes. Check the examples and readme. They will display on the page the way they are configured to display from the backend.


Field group can create tab groups (horizontal and vertical) and tab elements on the same view mode. Than you are able to access each tab with a hash. The ID of each tab becomes the has anchor (#company etc).

You have to setup the fields in 1 view mode and place them under the appropriate tabs.

Here is a screenshot of how the setup should look.

enter image description here

  • thank you for your answer, but I am currently using the exact thing what you have described above. However, the idea I don't want when the user access "Company" information to be able to access as well the "Activities" information by a switching of a tab... (It is really a design based specific requirement) – Elie Masaad Apr 13 '19 at 11:19
  • @ElieMasaad you can't have hash based urls on different pages, but you can decide to hide them with javascript and will be able to see them only with the use of the appropriate tab. Perhaps your requirement is not clearly explained. – GiorgosK Apr 13 '19 at 12:31
  • can you please check my Update #1 to the question – Elie Masaad Apr 13 '19 at 13:47

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.