0

I am trying to build a breadcrumb using JS and SPServices. When I browse for a page like

http://sharepoint.com/sites/News/pages/f1/f2/default.aspx 

the breadcrumb should show

SharePoint.com > f1 > f2 > Page Title

Each node should have hyperlink to their URL accordingly.

By using $().SPServices.SPGetCurrentSite(), that is http://sharepoint.com/sites/News/ in above example.

However I have no idea how to get the suffix, or relative path, of the site or subsite (i.e. pages/f1/f2/default.aspx)

By using window.location.pathname, I will get /sites/News/pages/f1/f2/default.aspx which is not my need. I need to get /pages/f1/f2/default.aspx only.

Also, I have some subsites with URL like:

http://sharepoint.com/sites/News/subsite/ http://sharepoint.com/sites/News/subsite/subsub/ http://sharepoint.com/sites/News/subsite/subsubsub/ 

Hence I need a function always return the "relative path" of the current site. Does this function exist?

2
  • Are you using SP2013? Commented Jun 30, 2015 at 6:31
  • Yes. SP2013 on-premise standard edition Commented Jun 30, 2015 at 6:41

2 Answers 2

4

Mark, See if this can help you.

If you are writing the custom code this can set you the starting point.

1
  • Thanks for the tips. But the OOB breadcrumb do not work on publishing infrastructure pages. I need to build my own. Commented Jul 2, 2015 at 1:33
0

I see you are using an on-prem version, so I suggest using out-of-the-box ways of achieving this.

In the masterpage there should already exist tools to help you achieve this.

In SharePoint 2010 (I haven't fooled around with Masterpages in 2013 a lot) the way to solve what you are asking for was to do this:

<div name="onetidProjectPropertyTitle"> <asp:ContentPlaceHolder ID="PlaceHolderSiteName" runat="server"> <SharePoint:SPLinkButton runat="server" NavigateUrl="~site/" ID="onetidProjectPropertyTitle"> <SharePoint:ProjectProperty ID="ProjectProperty1" Property="Title" runat="server" /> </SharePoint:SPLinkButton> </asp:ContentPlaceHolder> </div> <span id="onetidPageTitleSeparator" class="s4-nothome s4-bcsep s4-titlesep"> <SharePoint:ClusteredDirectionalSeparatorArrow ID="ClusteredDirectionalSeparatorArrow1" runat="server" /> </span> <asp:ContentPlaceHolder ID="PlaceHolderPageTitleInTitleArea" runat="server" /> 

I'm sure there exist 2013 equivalents of this. You might have to throw in a bit of your own HTML markup to make it look the way you want.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.