2015-08-30 2 views
0

J'ai les deux vues similaires dans lesquelles les bourres de pain MVCSiteMap sont invisibles. Sur les autres pages, le même code fonctionne. Aidez-moi s'il vous plaît à comprendre pourquoi ces deux points de vue ne montrent pas de pain. Code Mvcsitemap:Les grains de pain MvcSiteMap ne sont pas visibles

<?xml version="1.0" encoding="utf-8" ?> 
<mvcSiteMap xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
      xmlns="http://mvcsitemap.codeplex.com/schemas/MvcSiteMap-File-4.0" 
      xsi:schemaLocation="http://mvcsitemap.codeplex.com/schemas/MvcSiteMap-File-4.0 MvcSiteMapSchema.xsd"> 

    <mvcSiteMapNode title="Главная" controller="Home" action="Index" key="Home"> 

    <mvcSiteMapNode title="Каталоги" controller="Products" action="Index" key="Products" /> 
    <mvcSiteMapNode title="Продукция" controller="Products" action="ProductList" key="ProductList" /> 
    <mvcSiteMapNode title="Новинки" controller="Products" action="ShowNewest" key="ShowNewest" /> 
    <!--Education--> 
    <mvcSiteMapNode title="Обучение" controller="Education" action="Index" key="Education"> 
     <mvcSiteMapNode title="Видео" controller="Education" action="Video" key="Video" /> 
     <mvcSiteMapNode title="Мастер-классы видео" controller="Education" action="Video_MasterClass" key="Video_MasterClass" /> 


     <mvcSiteMapNode title="Отзывы участников" controller="Education" action="FeedbacksParticipants" key="FeedbacksParticipants"> 

     <!--THIS IS THE FIRST PROBLEM-->  
     <mvcSiteMapNode title="Отзыв участника" controller="Education" action="OneFeedbacksParticipants" key="OneFeedbacksParticipants" /> 
     </mvcSiteMapNode> 


     <mvcSiteMapNode title="Полное рассписание семинаров" controller="Education" action="AllSeminars" key="AllSeminars" /> 
     <mvcSiteMapNode title="Семинары по уходу за лицом" controller="Education" action="FaceSeminars" key="FaceSeminars" /> 
     <mvcSiteMapNode title="Семинары по уходу за телом" controller="Education" action="BodySeminars" key="BodySeminars" /> 
     <mvcSiteMapNode title="Информация о интересующем семинаре" controller="Education" action="ShowOneSeminar" key="ShowOneSeminar" /> 
     <mvcSiteMapNode title="Тренинги для руководителей" controller="Education" action="TrainingsForChiefs" key="TrainingsForChiefs" /> 
     <mvcSiteMapNode title="Тренинги по продажам" controller="Education" action="TrainingsForSalers" key="TrainingsForSalers" /> 
     <mvcSiteMapNode title="Информация о интересующем тренинге" controller="Education" action="ShowOneTraining" key="ShowOneTraining" /> 
    </mvcSiteMapNode> 
    <!--News--> 
    <mvcSiteMapNode title="Новости" controller="News" action="AllNews" key="AllNews" /> 
    <mvcSiteMapNode title="Новость" controller="News" action="News" key="News" /> 
    <!--Partners--> 
    <mvcSiteMapNode title="Партнеры" controller="Partner" action="AllPartners" key="Partners" /> 
    <mvcSiteMapNode title="Партнер" controller="Partner" action="Partner" key="OneOfPartners" /> 
    <!--About company--> 
    <mvcSiteMapNode title="О нас" controller="Home" action="AboutUs" key="AboutUs" /> 
    <mvcSiteMapNode title="О бренде" controller="Home" action="AboutBrand" key="AboutBrand" /> 
    <mvcSiteMapNode title="Пресса" controller="Social" action="Press" key="Press" /> 
    <mvcSiteMapNode title="Статья" controller="Press" action="Press" key="Article" /> 

    <mvcSiteMapNode title="Отзывы" controller="Social" action="Feedback" key="Feedback"> 

     <!--THIS IS THE SECOND PROBLEM-->  
     <mvcSiteMapNode title="Отзыв подробнее" controller="Social" action="OneFeedback" key="OneFeedback" /> 
    </mvcSiteMapNode> 


    <!--Contacts--> 
    <mvcSiteMapNode title="Контакты" controller="Home" action="Contacts" key="Contacts" /> 
    <!--Sertificartes--> 
    <mvcSiteMapNode title="Сертификаты" controller="Sertificates" action="Index" key="Sertificates" /> 

    </mvcSiteMapNode> 

</mvcSiteMap> 

code dans le contrôleur (Education):

[MvcSiteMapNode(Title = "Отзыв участника", ParentKey = "FeedbacksParticipants")] 
     public ActionResult OneFeedbacksParticipants(Int32 id) 
     { 
      ViewBag.Title = "Отзывы участников"; 
      ViewBag.Description = "Отзывы об обучении в Астрамед"; 
      ViewBag.Keywords = "Астрамед, отзывы, обучение, семинары, тренинги, лицо, тело, косметика"; 
      FeedbackOfParticipantManager manager = new FeedbackOfParticipantManager(); 
      FeedbackModel model = manager.GetFeedback(id); 
      return View(model); 
     } 

code dans le contrôleur (social):

[MvcSiteMapNode(Title = "Отзыв подробнее", ParentKey = "Feedback")] 
     public ActionResult OneFeedback(Int32 id) 
     { 
      ViewBag.Title = "Отзыв подробнее"; 
      ViewBag.Description = "Отзывы об Астрамед"; 
      ViewBag.Keywords = "Астрамед, Tegor, отзывы"; 

      FeedbackManager feedbackManager = new FeedbackManager(); 
      FeedbackModel model = feedbackManager.GetFeedback(id); 
      return View(model); 
     } 

Dans les vues que j'ai le code suivant:

<div class="breadcumbs">@Html.MvcSiteMap().SiteMapPath()</div> 

Merci beaucoup

Répondre

0

Le problème est que vous n'avez pas défini quoi faire avec le paramètre id dans votre configuration. Par défaut, vous devez créer un nœud pour chaque id possible.

Cela ne serait probablement pas pratique dans ce cas. L'autre option consiste à configurer une relation un-à-plusieurs en forçant chaque id à correspondre en utilisant PreservedRouteParameters.

[MvcSiteMapNode(Title = "Отзыв участника", ParentKey = "FeedbacksParticipants", PreservedRouteParamters="id")] 
public ActionResult OneFeedbacksParticipants(Int32 id) 
{ 
    ViewBag.Title = "Отзывы участников"; 
    ViewBag.Description = "Отзывы об обучении в Астрамед"; 
    ViewBag.Keywords = "Астрамед, отзывы, обучение, семинары, тренинги, лицо, тело, косметика"; 
    FeedbackOfParticipantManager manager = new FeedbackOfParticipantManager(); 
    FeedbackModel model = manager.GetFeedback(id); 
    return View(model); 
} 

[MvcSiteMapNode(Title = "Отзыв подробнее", ParentKey = "Feedback", PreservedRouteParamters="id")] 
public ActionResult OneFeedback(Int32 id) 
{ 
    ViewBag.Title = "Отзыв подробнее"; 
    ViewBag.Description = "Отзывы об Астрамед"; 
    ViewBag.Keywords = "Астрамед, Tegor, отзывы"; 

    FeedbackManager feedbackManager = new FeedbackManager(); 
    FeedbackModel model = feedbackManager.GetFeedback(id); 
    return View(model); 
} 

Références:

https://github.com/maartenba/MvcSiteMapProvider/wiki/Routing-Basics http://www.shiningtreasures.com/post/2013/09/02/how-to-make-mvcsitemapprovider-remember-a-user-position

REMARQUE: Vous ne devez déclarer le nœud une fois, que ce soit en XML ou comme un attribut .NET.