I am rolling out a number of custom pages using a page template feature approach. I am also using a custom master page for these pages. As part of the design, we would like the Quick Launch menu for the custom pages to hide Libraries and Discussion categories, and add a few custom links. I found How to customize Quick Launch bar walkthrough. However, the changes in it are global to the site. Is there a way to localize changes to a specific page?
3 Answers
You already answered half of your question. You cannot customize Quick Launch by changing SPNavigationNodeCollection on server side because your changes are then applied globally.
So you are left with one reasonable option - to do it on client side with some javascript. I would suggest that you use jQuery for the sake of simplicity. To hide Libraries header you can use following script:
$("div[id*='V4QuickLaunchMenu'] span:contains('Libraries')").parents("li").hide()
You can simply add your javascript to page by using Content Editor WebPart : http://sptwentyten.wordpress.com/2010/08/31/insert-javascript-into-a-content-editor-web-part-cewp/
General disadvantage of using client side script for this manipulation is that header can be visible for a brief moment before script loads and executes.
The best suggestion I can make is wrap the desired change functionality into a web part and only put that web part on the pages you want to affect. You can do pretty much anything you would conceivable want to do with a master page with a couple lines of server-side code or javascript.
The timing of your question is good, as I'll be publishing a freebie web part (...along with source) that does this early-mid next week. You just add it to the page (it's hidden) and then configure in the web part settings what you want to hide.
I implemented this method and for me it works fine!
http://webdevshareetc.blogspot.it/2012/09/sharepoint-2010-customizing-quick.html
Bye!
-
Welcome to SharePoint.se! While this may theoretically answer the question, we prefer inclusion of the essential parts of the answer here, and to provide the link for reference. See How to Answer for general guidelines. Nov 19, 2012 at 21:18