1

I have the following :-

  1. SharePoint server 2013 web application.
  2. the web application contains two site collections of type enteprise wiki.
  3. i have enabled metadata navigation for the two site collection, and i enable Tree view.
  4. the result is that i got my managed metadata on the left site of my screen, as follow:-

enter image description here

5.but if i click on a term (for example Hardware) it will not filter the pages, instead the current page will reload.

i find the following link which talks about the same problem link. but i am not sure how i can add this method to my site collections:-

public class CustomWikiPageBase : PublishingLayoutPage
{
    protected override void OnInit(EventArgs e)
    {
        if (!String.IsNullOrEmpty(Request.QueryString["TreeField"]) 
            && !String.IsNullOrEmpty(Request.QueryString["TreeValue"]))
        {
            Response.Redirect(String.Format("{0}?TreeField={1}&TreeValue={2}",
                SPContext.Current.ListItem.ParentList.DefaultViewUrl,
                Request.QueryString["TreeField"],
                Request.QueryString["TreeValue"]));
        }
        else if (!String.IsNullOrEmpty(Request.QueryString["TreeField"]))
        {
            Response.Redirect(String.Format("{0}?TreeField={1}",
                SPContext.Current.ListItem.ParentList.DefaultViewUrl,
                Request.QueryString["TreeField"]));
        }
        base.OnInit(e);
    }
}

i mean should i create a new sandbox solution, farm solution, or visual web part inside visual studio ? and how i can deploy the solution to my web application, can anyone advice on this please ?

6
  • how are you filtering the pages? with search?
    – Gwny
    Dec 8, 2014 at 16:35
  • What is the issue you are encountering with the link you provided?
    – Dave
    Dec 8, 2014 at 21:00
  • @Dave as mentioned in point 5 inside my original question, the problem that i enabled meta data navigation inside a library + i enable tree view on the site collection. then a term store will be displayed on the left-hand side of the screen. but if i click on certain term , the current page will reload, instead of that when clicking on a term , it should filter the pages which are linked to the term. seems this will not work out-of-the-box in SharePoint, and to allow this to work i have to add the above OnInit() method.
    – John John
    Dec 9, 2014 at 11:49
  • so my questions are basically, 1) how i should add this custom code, for example as web part,etc ? second question if there is a way to get metadata navigation to work without adding any custom code ?
    – John John
    Dec 9, 2014 at 11:49
  • As stated in the answer I've provided: The method provided in the link you are following wants you to put it in a CodeBehind file referenced by your custom page layout.
    – Dave
    Dec 9, 2014 at 15:21

2 Answers 2

0

I'm not entirely sure what you're asking, but I'm going to assume you are having trouble figuring out where the code you've pasted here is supposed to go.

The link you've provided suggests that you add it to the Codebehind for the pagelayout.ASPX that you are creating.

This link explains how to add a codebehind file to an ASPX page:

8
  • but is there a way to get metadata navigation to work without adding any extra code ?
    – John John
    Dec 9, 2014 at 11:50
  • to get this working partially ,I create a new Visual Web Part project inside visual studio, then i deploy the feature to SharePoint , and i added the web part to the welcome page for my site collection, and i get the metadata navigation working. but the problem with my approach , is that users might remove the web part form the welcome page , which will stop metadata navigation from working ..
    – John John
    Dec 9, 2014 at 11:53
  • Ok so the link you provided said to put it in the code behind file referenced by your page layout...
    – Dave
    Dec 9, 2014 at 14:39
  • ok sound valid, but why sharepoint does not have this working out-of-the-box ,, i mean when you enable tree view at the site collection level & enable metadata navigation for the list ,, then why the metadata navigation does not work ?
    – John John
    Dec 9, 2014 at 15:36
  • also the link you provide pinnacleofindiana.com/blog/developers/2012/03/28/… is assuming that i have created a custom page layout using visual studio , while in my case i used the SharePoint designer to create a new custom page layout ... so the link is not valid in my case
    – John John
    Dec 9, 2014 at 15:38
0

You may want to rephrase your question. I am not sure what your end goal is, but if it is to use a term set to navigate through your site, then watch this video: https://www.youtube.com/watch?v=7ICmKCSGS7M

1
  • He is trying to use metadata navigation within a wiki library, which is known to not function very well. He has provided a link that he is following which solves the issue. I have followed the link he provided and it worked, but he doesn't really seem to understand what the link ios telling him to do. When I explained to him what he had to do he basically said he didn't want to and that my answer was invalid. His initial question was where do I put this code I've pasted, but he doesn't want to accept an answer until someone provides him with a complete solution.
    – Dave
    Dec 15, 2014 at 15:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.