Forum Discussion

Vincent1230's avatar
Vincent1230
Copper Contributor
Oct 09, 2023

Create dynamic navigation link to each user's personal page in SharePoint

Hello,

 

I'm trying to add a Navigation link (or just a link in the homepage) to each user's personal page on my SharePoint Site. The goal is that when any user views the homepage, they would see a "My Page" link that takes them directly to their own personalized page.

 

How can I realize this function?

 

Thanks in advance.

 

  • Hi Vincent1230,

    you could do this:

    1) Create a new list "MyPages" and add a new hyperlink column "link" and a people column "person" to it.
    2) Now add all of your users to that list and link to the mypage.
    3) Then create a new gallery view that filters the items to only display those items that have the current user in the "person" column.
    4) Format that view using this formatting sheet

    {
      "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/tile-formatting.schema.json",
      "height": "40px",
      "width": "100px",
      "hideSelection": true,
      "formatter":  {
    		"elmType": "a",
            "txtContent": "My Page",
    		"attributes": {
    			"class": "sp-card-defaultClickButton",
    			"role": "presentation",
    			"target": "_blank",
    			"href": "=[$Link]"
    		},
    		"style": {
    			"padding": "10px",
    			"height": "32px",
    			"margin-right": "8px",
    			"margin-botton": "10px",
    			"font-size": "14px",
    			"border-radius": "2px",
    			"border": "none",
    			"font-weight": "600",
    			"background-color": "#0078d4",
    			"cursor": "pointer",
    			"color": "white",
    			"text-decoration": "none",
    			"text-align": "center",
    			"width": "80px"
            }
    	}
    }

    The result should look like this

    5) Use the list view webpart to embed this on your homepage

    Best Regards,
    Sven

  • SvenSieverding's avatar
    SvenSieverding
    Bronze Contributor

    Hi Vincent1230,

    you could do this:

    1) Create a new list "MyPages" and add a new hyperlink column "link" and a people column "person" to it.
    2) Now add all of your users to that list and link to the mypage.
    3) Then create a new gallery view that filters the items to only display those items that have the current user in the "person" column.
    4) Format that view using this formatting sheet

    {
      "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/tile-formatting.schema.json",
      "height": "40px",
      "width": "100px",
      "hideSelection": true,
      "formatter":  {
    		"elmType": "a",
            "txtContent": "My Page",
    		"attributes": {
    			"class": "sp-card-defaultClickButton",
    			"role": "presentation",
    			"target": "_blank",
    			"href": "=[$Link]"
    		},
    		"style": {
    			"padding": "10px",
    			"height": "32px",
    			"margin-right": "8px",
    			"margin-botton": "10px",
    			"font-size": "14px",
    			"border-radius": "2px",
    			"border": "none",
    			"font-weight": "600",
    			"background-color": "#0078d4",
    			"cursor": "pointer",
    			"color": "white",
    			"text-decoration": "none",
    			"text-align": "center",
    			"width": "80px"
            }
    	}
    }

    The result should look like this

    5) Use the list view webpart to embed this on your homepage

    Best Regards,
    Sven

    • Vincent1230's avatar
      Vincent1230
      Copper Contributor

      Hi SvenSieverding,

       

      Thank you so much for your reply!

       

      I successfully made the dynamic personalized link as intended! However, I have a few additional questions regarding the style:

       

       

       1. The "My Page" Button is not centered. Is it possible to edit the view formatting to center align the "Button"?

       

      2. I also notice there are horizontal and vertical scrollbars on the view. Is there a way to remove these?

       

      3. There seems to be a lot empty space below the "button". Can the view height be adjusted to reduce the blank area?

      Thank you again for your time and for sharing your expertise, it's much appreciated! Please let me know if you have any other suggestions.

       

      Best Regards,

      Vincent

Resources