Nombre de messages:
15
Karma:
125
Inscrit:
06/07/2009
Localisation:
Canada
Hi, I am trying to use the Item.Description in my category listing : /Views/Catalog/CategoryTemplate.ProductsInGridOrLines.cshtml I am using that code : @Html.Raw(item.Description) It is working fine, but the localization is not working. When I switch language, it took the standard version. Any help will be very appreciate. Thanks, Nicolas
Nombre de messages:
16637
Karma:
156200
Inscrit:
22/10/2008
Localisation:
Armenia
I presume that you're using not a category description (something else) because it should be referenced by Model.Description (not item.Description). Where exactly are you using it in /Views/Catalog/CategoryTemplate.ProductsInGridOrLines.cshtml?
Nombre de messages:
15
Karma:
125
Inscrit:
06/07/2009
Localisation:
Canada
It is returning nothing if I use the Model.Description. @if (Model.SubCategories.Count > 0) { <div class="sub-category-grid "> @(Html.DataList<CategoryModel.SubCategoryModel>(Model.SubCategories, itemPerRow, @<div class="item-box @widthItem"> <div class="sub-category-item @widthItem"> <h2 class="category-title"> <a href="@Url.RouteUrl("Category", new { categoryId = item.Id, SeName = item.SeName })" title="@item.PictureModel.Title"> @item.Name</a> </h2> <div class="picture"> <a href="@Url.RouteUrl("Category", new { categoryId = item.Id, SeName = item.SeName })" title="@item.PictureModel.Title"> <img style="border-width: 0px;width:150px;" alt="@item.PictureModel.AlternateText" src="@item.PictureModel.ImageUrl" title="@item.PictureModel.Title" /></a> <p>@Html.Raw(@item.Description) </p> </div> </div> </div> )) </div> <div class="clear"> </div> }
Nombre de messages:
16637
Karma:
156200
Inscrit:
22/10/2008
Localisation:
Armenia
Actually CategoryModel.SubCategoryModel class doesn't have Description property which you're using. So you customized the source code. BTW, you're trying to display the localized description of subcategories (not the main category). How exactly have you changed the 'Category ' method of the 'CatalogController ' (how are you setting this Description property)?
Nombre de messages:
15
Karma:
125
Inscrit:
06/07/2009
Localisation:
Canada
Ok, sorry I didn't remember I had changed the controller : CatalogController.cs That is the problem, I have add this line : //subcategories model.SubCategories = _categoryService .GetAllCategoriesByParentCategoryId(categoryId) .Select(x => { var subCatName = x.GetLocalized(y => y.Name); var subCatModel = new CategoryModel.SubCategoryModel() { Id = x.Id, Name = subCatName, Description = x.Description, SeName = x.GetSeName(), }; subCatModel.PictureModel.ImageUrl = _pictureService.GetPictureUrl(x.PictureId, _mediaSetting.CategoryThumbPictureSize, true); subCatModel.PictureModel.Title = string.Format(_localizationService.GetResource("Media.Category.ImageLinkTitleFormat"), subCatName); subCatModel.PictureModel.AlternateText = string.Format(_localizationService.GetResource("Media.Category.ImageAlternateTextFormat"), subCatName); return subCatModel; }) .ToList(); What I need to add to the return value to get the localization working ?
Nombre de messages:
15
Karma:
125
Inscrit:
06/07/2009
Localisation:
Canada
Ok it working now ... I change the controller code for these : //subcategories model.SubCategories = _categoryService .GetAllCategoriesByParentCategoryId(categoryId) .Select(x => { var subCatName = x.GetLocalized(y => y.Name); var subCatDesc = x.GetLocalized(y => y.Description); var subCatModel = new CategoryModel.SubCategoryModel() { Id = x.Id, Name = subCatName, Description = subCatDesc, SeName = x.GetSeName(), }; subCatModel.PictureModel.ImageUrl = _pictureService.GetPictureUrl(x.PictureId, _mediaSetting.CategoryThumbPictureSize, true); subCatModel.PictureModel.Title = string.Format(_localizationService.GetResource("Media.Category.ImageLinkTitleFormat"), subCatName); subCatModel.PictureModel.AlternateText = string.Format(_localizationService.GetResource("Media.Category.ImageAlternateTextFormat"), subCatName); return subCatModel; }) .ToList(); Many thanks for your help ! Nicolas