Navigation from a 'My Site' back to a Site Collection

I don’t normally do much with My Sites to be honest – usually I’m building applications, and they’re not usually in My Sites. One of our customers asked me ‘How do users navigate back to the Intranet?’ and I’ve got to admit, I was baffled.

Well, SharePoint’s My Sites have a site-collection setting for ‘Portal Site Collection’. This setting modifies the Global Breadcrumb, and inserts another link there – so you can have a link back to your site-collection.

There a number of issues with that, though… Continue reading “Navigation from a 'My Site' back to a Site Collection”

Advertisement
Navigation from a 'My Site' back to a Site Collection

My Sites links HoverCellActive doesn't show the top border

This has caught me out three times now – I build style, but the top border for the global links ‘My Links’ link didn’t show:

I checked my style, and there it was. So I tried adding a margin, or padding in the cell that contained it.

Wrong. It needs it’s height to be set to 100%.

.ms-globalbreadcrumb .ms-HoverCellActive,
.ms-globalbreadcrumb .ms-HoverCellInctive,
.ms-globalbreadcrumb .ms-HoverCellActiveDark{
height:100%;
padding-top:1px;
}

My Sites links HoverCellActive doesn't show the top border

Putting a web part zone below the quick navigation menu

Previously, I’d been asked to put a web part zone below the quick nav for SharePoint pages. As it transpires, you can’t put web part zones on master pages – but there is no reason why you shouldn’t put one in an asp:Content control (indeed, that’s how you have to place them on pages). And I’d noticed this PlaceHolderLeftActions content placeholder. So I figured, why not put my web part zone into that?

To do this, I need to modify the page that I want this zone to appear for. It could be a Page Layout for publishing pages, or just a normal default.aspx on a team site. I’m using a blank site for this. I simply added a Content control, and dropped a web part zone into it:

<asp:Content ContentPlaceHolderId="PlaceHolderLeftActions" runat="server">
<WebPartPages:WebPartZone id="g_5AD648BF053647678E80875B48A60593" runat="server" title="Zone 1">
</WebPartPages:WebPartZone>
</asp:Content>

I saved the changes, and now when I go to edit that page I see:

Great! I can drop in web parts – here I’ve used a summary links web part:

But you may find the styling leaves something to be desired – but you can design that in!

Sure, you could find that you have to do this a lot of times if you want to do this for many pages, but if you’re using the publishing features, you only have to modify each Page Layout once, which is very handy.

Putting a web part zone below the quick navigation menu

Updating the Navigation Settings in a Publishing Site

I’ve got a brand that I’m activating via a Feature Receiver – it’s a theme and masterpage combination, and I want it to work on Team sites too, so it does actually make sense to do it this way!

Part of the brand is that the tabs have rounded corners, and these don’t work very well with the dynamic drop down menus. You can turn this off in the master page for the site pages, but not for the applications pages. Instead, I figured I’d use a feature receiver to turn off the ‘Show Subsites’ and ‘Show Pages’ in a publishing site.

So, the code I had was this:

if (PublishingWeb.IsPublishingWeb(site))
{
PublishingWeb pwSite = PublishingWeb.GetPublishingWeb(site);
site.Properties[ORIG_PUB_SITES] = pwSite.IncludeSubSitesInNavigation.ToString();
site.Properties[ORIG_PUB_PAGES] = pwSite.IncludePagesInNavigation.ToString();
site.Properties.Update();

pwSite.IncludePagesInNavigation = false;
pwSite.IncludeSubSitesInNavigation = false;
pwSite.Update();
pwSite.Close();
}

However, this didn’t work. To describe the code, first, we check to see if the page is a PublishingWeb. If it is, I record original settings in the site properties (so I can restore them when the feature is deactivated). I turn off those navigation check boxes, update the record on the server and close the object.

After much investigation, I realised that updating the properties was invalidating the PublishingWeb object, somehow, and that my changes weren’t being recorded. In the end I had to change my code to:

if (PublishingWeb.IsPublishingWeb(site))
{
PublishingWeb pwSite = PublishingWeb.GetPublishingWeb(site);
bool showPages = pwSite.IncludePagesInNavigation;
bool showSub = pwSite.IncludeSubSitesInNavigation;

pwSite.IncludePagesInNavigation = false;
pwSite.IncludeSubSitesInNavigation = false;
pwSite.Update();
pwSite.Close();

site.Properties[ORIG_PUB_SITES] = showPages.ToString() ;
site.Properties[ORIG_PUB_PAGES] = showSub.ToString() ;
site.Properties.Update();
}
This worked nicely!

Updating the Navigation Settings in a Publishing Site

SharePoint: Enabling Dynamic Navigation on the Left Nav Menu

I’ve been modifying SharePoint’s Left nav menu, as I’m sure I’ve mentioned. Well, here’s the before and after styling, for the curious:

The next requirement that came up was to enable Dynamic menus on the left navigation. This is actually pretty easy:

  1. Open up your master page in SharePoint Designer
  2. Find the sharepoint:aspmenu control for the left nav
  3. Set the MaximumDynamicDisplayLevels to 1 or more

As an experiment, I did this (I’ve highlighted the dynamic menu ‘cos it wasn’t really styled yet, and so wasn’t very visible):

However, we’ve just hit a snag. It started right at the point where we editted our master page.

You’ll notice that the page has a ‘View All Site Content‘ link. This goes to the page viewlsts.aspx – which is an application page in the LAYOUTS directory, and so does not use our master page and will not have our dynamic menus.

Arse. Where does it get this left hand navigation then? Most Application Pages don’t have any left navigation. viewlsts.aspx defines it’s own – which happens to be identical to the default content of the default master page’s left nav.

So what can we do? We can’t modify viewlsts.aspx – it’s in the _layouts directory, and Microsoft are specific about not modifying stuff in there.

  • Remove all links to it, pretend it isn’t there. I’d sooner not – it’s a useful page.
  • Live with it. So the View All Site content page has navigation inconsistent to the rest of the site – get over it.
  • Increase the permissions to see the View All Site Content link. By default, it’s presented inside an SPSecurityTrimmedControl, just with very low permissions defined. Increase this to admin level, and then have them live with inconsistent navigation on the ‘admin’ page
  • Replace viewlsts.aspx.

We can’t modify viewlsts.aspx – but we can replace it. We could take a copy, and modify that – Microsoft don’t mind that – to use our dynamic navigation. We can put this new copy in the _layouts directory. We’ll then need to update the links in our site:

  1. One link is coded into the master page. Just update the URL the SPLinkButton to it.
  2. The other is in the Site Actions Menu. This ought to be possible, but I haven’t really had a look yet.

Hope that helps!

SharePoint: Enabling Dynamic Navigation on the Left Nav Menu

PlaceholderLeftActions – what is it?

I’ve been doing some branding for the last week or so, and today was the turn of the left nav menu. I’ve gotta admit, I don’t like doing this – it’s complex, fiddly, and leaves me with what I call “SharePoint Branding Tourettes”.

While going through the code for the left side of the page, I came across the PlaceHolderLeftActions placeholder. By default, it’s empty.

It was a bit of a puzzle to me though – it sits just underneath the normal left navigation area of the page, and I couldn’t think of anything that puts content down there. Just to check though, I took a look in IE Explorer:

I’ve highlighted where the content goes, and you can see from the IE dev bar, there is a hidden link there (to the List Settings page, if you’re interested).

Hmm. So some stuff uses it. I tried different lists in case they all used hidden content – and fairly rapidly came across another – Wiki pages:

I guess the real annoyance here is that it is so hard to see what pages in SharePoint use what placeholders. It’s not like you can just search over the file system, even. I guess it’s a matter for experience.

Anybody else know what the PlaceHolderLeftActions is used for? I might try and build up a library.

PlaceholderLeftActions – what is it?

Remove a Separator Character from the Global Links

I ain’t dead, just flat out busy. I’m working on a branding project at the moment, which I hope to write some more about. But here’s a tricky little problem that I was struggling with.

Our customer wanted to remove the ‘Help’ and ‘My sites’ links from the Global Links in the top right of the page (the Mysite link is going elsewhere on the page), so I removed these items from my new master page. I ended up with something like this:

I’ve highlighted the problem in yellow – a spurious trailing ‘|’ character which is being used as a seperator between links. I didn’t want this though! Looking at the code in my master page, though, showed that this link was being generated by a Delegate control:

Oookay. Not sure why the default value for this is coming from a delegate control, but there you go. Let’s have a look at the code for that delegate control:

Right, so the code is held in a control template -fair enough, let’s look in there:

There we go – a literal control. I have no idea what’s putting that separator character into the literal – and I don’t want to define my own delegate control to override the current delegate control.

So what to do? Well, simple answer – I copied the MyLinksMenuControl into my master page (but without any damn asp:Literal control). All this raises two questions though:

  1. Why are some of the Global links (though not all) rendered via Delegate controls?
  2. Who thought that rendering the control with a separator was a good idea?

All in all, it seems to be absurdly complex and highly effort-filled if you want to change anything here.

Remove a Separator Character from the Global Links

Creating a SiteMapProvider for SharePoint

Interesting stuff about creating a SiteMapProvider on ‘Tomblog’ (but Tom who?)

Note 1 – I guess he inherited from SPNavigationProvider or SPXmlContentMapProvider as SPSiteMapProvider and SPContentMapProvider are both sealed.

Note 2 – He doesn’t mention caching. I kind of wonder how that would work.

Still, interesting stuff – might have a look sometime as part of my ‘one breadcrumb only’ campaign.

Creating a SiteMapProvider for SharePoint

Limiting the levels shown in SharePoint Breadcrumbs

This was such a good question, I thought I’d reply in a post about it:

I am trying to limit the depth of the breadcrumbs. I have a sub sub sub subsite that I want breadcrumbs to show from that site and down one more level. I can make the breadcrumbs invisible using SPD but I wonder if I can make them limited … like we could in WSS 2. – Jo Arnspiger

Well, there are a couple of ways that spring to mind (there are many approaches, but these are probably the best two) – one that uses SharePoint Designer, and one that uses SharePoint’s own navigation configuration.

First off, let’s look at the SharePoint Designer route. If you go to your master page or page layout, you’ll see an ASP control called the SiteMapPath control. It has a property called ParentLevelsDisplayed.

A SiteMapPath control showing the ParentLevelsDisplayed property.

Set that to a number, and that should be the maximum number of levels shown. If you set it to -1, it will show however many levels there are, which is it’s default. (I’ve not tried it, but I’m pretty sure that’s the case). That’s probably what you want, but there is a problem – it’s not just your master page which defines the SiteMapPath control. There is one on most of the Publishing Page layouts that come out of the box too. Still, if you’re happy taking a little time to change all of them, then that’s probably fine.

The other problem is a little more fundamental – this setting will apply across your entire site collection. Well, okay, maybe not, but it’ll apply for all pages using that master page or page layouts…

Alternatively, you could change the Site’s navigation settings to get what you want. At the ‘sub sub sub subsite‘ you could change the site’s navigation setting to not inherit it’s top navigation settings from the parent site. This will add a level to the ‘Global Navigation’ breadcrumb, but also make all URLs below the ‘sub sub sub subsite‘ start at that level. See my previous article for an explanation.

The down side about this approach, though, is that it means all of your top navigation tabs will change – you really are breaking with the ‘navigation context’ of the parent site. (That’s my term – I didn’t know what else to call it.) There is an example of this on the article linked to above.

A final note, these approaches do have two slightly different results – the first route is a ‘only show the last X items’, while the second is ‘chop all breadcrumbs below this site to start here’.

Anyway Jo, I hope that one of those is suitable.

Limiting the levels shown in SharePoint Breadcrumbs

Advanced Search – Losing Parameters

I have a bit of a problem with Advanced Search in SharePoint – it’s very awkward to use.

When I perform a standard search in SharePoint, it shows me what I’ve been searching for:

Search Results showing Search Term of Snake

That’s good – it’s useful to know what you’ve searched for. If I then click on ‘Advanced’ the advanced search page opens showing my search term, and a number of other fields I can fill in for a more specific search.

Advanced Search Screen with Search term of Snake

If I then run that search, though, I get the following results page:

Search results, but with no apparent search term

Okay, now that is a little odd looking. There is no search term in the search input box. This is perhaps not surprising – the advanced search screen can express more complex queries than the text input box of the simple search control. However, there is nothing to tell you what the results are of. You have no idea what the search was that gave these results!

Worse happens if you try to go back to your advanced search page. Unless you use the browser’s Back button, you will lose your current query. There is no obvious way of ‘refining’ an advanced query.

It looks like this is happening because the simple Search box passes it’s parameters in the URL as GET parameters, but the Advance Search page uses a postback-then-forward approach.

Is it too much to ask for to have a web part that describes what the conditions of an advanced search are, and to store that query to pass back to the Advanced Search page, should the user wish to refine their query.

Advanced Search – Losing Parameters