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

Breadcrumb Path Separator and Path Direction

There are several settings you can apply to breadcrumbs in MOSS, although really some of these are really ASP.NET settings rather than most specific. Previously I’ve mentioned using different SiteMapProviders and rendering the current location as a link. Let’s have a look at another couple of settings:

Examples of various breadcrumb settings and different SiteMapProvider's output

(Yes, this screenshot shows some other settings – they’re mentioned in the other articles)

Looking at the screenshot we can see how the Path Separator setting allows us to set what we want shown between nodes – rather than ” > ” I’ve used “:”. Not sure when/why you’d want to change that, but I’m sure I’ll be given a design where that is useful sometime!

There’s also the Path Direction setting, which allows us to set whether the breadcrumb should have the current node on the left or right of the breadcrumb – hence the two settings, RootToCurrent and CurrentToRoot. Note, though, that the default path separator doesn’t swap from ” > ” to ” < “.

Breadcrumb Path Separator and Path Direction