glass-mapper

Sitecore Glass Mapper (v4): Add custom query string parameter via RenderImage

◇◆丶佛笑我妖孽 提交于 2020-01-14 06:03:49
问题 Using Glass Mapper for Sitecore version 4 (MVC), I need the following method call: @Html.Glass().RenderImage(Model, x => x.PhotoField, new {cropregion = xmlValue.GetCropRegion()}, true, true) to result in: <img src="/sitecore/shell/-/media/Default-Website/cover.jpg?h=550&w=1600&la=en&hash=2986CA8291803D4A8EAC3B5A1C276E27D4877DCC&cropregion=534,11,1348,548" width="1600" height="550" /> Currently, the RenderImage call will result in the cropimage being added as an attribute rather than on the

Sitecore Glass Mapper always null

时光总嘲笑我的痴心妄想 提交于 2019-12-29 08:41:40
问题 I am using Sitecore Glass Mapper for a new project I'm setting up. We are using Sitecore 7.2, latest version of Team Development for Sitecore (TDS) code generation and the latest version of glass. The code I am trying to execute: var b = new SitecoreContext(); var c = b.GetCurrentItem<T01_Homepage>(); b is not null. c is null. var d = b.GetItem<T01_Homepage>("path") d is null. I added my assembly in GlassMapperScCustom: public static IConfigurationLoader[] GlassLoaders(){ var attributes = new

Glass Mapper RenderLink link description - default text if empty

二次信任 提交于 2019-12-25 06:20:29
问题 <li>@if (string.IsNullOrWhiteSpace(topLinks.Target.Text)) { topLinks.Target.Text = "EMPTY DESCRIPTION"; } @(RenderLink(topLinks, x => x.Target, isEditable: true)) </li> I need a way to catch it when a Content Editor has set up a link, but not actually put a Link Description in. At the moment it just renders spaces. The above works, but it's clunky and I need to put it everywhere I use a RenderLink . How do I default the text if it's empty? 回答1: I've created an extension method to work around

Sitecore Rich Text links not user friendly when rendered through Glass

為{幸葍}努か 提交于 2019-12-24 07:16:57
问题 I have a component that includes a single Rich Text field. In the sublayout, the field is rendered as an Html.Editable with Glass so that it can be edited on the page in PageEditor. It looks like this: public override void Initialize() { litBodyContent.Text = Html.Editable(GlassItem, item => item.Body); } <div style="min-height: 38px"> <asp:Literal runat="server" ID="litBodyContent" /> </div> However, when I insert links using the Rich Text editor, when the page is rendered (in normal view

Why isn't my Enumerable getting populated by Glass.Mapper?

若如初见. 提交于 2019-12-20 05:17:17
问题 I'm totally confused as to why this isn't working. I have a class with a list of other classes as a property of it: public class Widget { .... public virtual IEnumerable<WidgetButton> Buttons { get; set; } } [SitecoreType(TemplateId = "{B615973D-59F6-437E-9827-BA3A40068C69}", AutoMap =true)] public class WidgetButton : BasePage { [SitecoreField] public virtual string Title { get; set; } } My sitecore item has a TreeListEx with one item in it: and I'm reading this item thus: Widget widgetTest

Sitecore Glass Mapper ObjectToSwitchTo null reference in page editor

*爱你&永不变心* 提交于 2019-12-14 03:13:16
问题 I have the following structure as Template in visual studio : Under a page, i have one or more link root [SitecoreType(TemplateId = "{4AAA9A10-36C2-484F-A648-2BEF349F0052}", AutoMap = true)] public class LinkRoot : IBaseTemplate { [SitecoreChildren(InferType = true)] public virtual IEnumerable<LinkItem> Children { get; set; } [SitecoreInfo(SitecoreInfoType.TemplateId)] public virtual Guid TemplateId { get; set; } public Guid Id { get; set; } public string Language { get; set; } public ItemUri

Using Glass Mapper's @inherits GlassView<T> with MVC 5.0 views

淺唱寂寞╮ 提交于 2019-12-13 05:09:09
问题 I recently updated my solution to MVC 5 and I am facing the following issue. It appears as though I can no longer format the code in any of my Views that utilize @inherits GlassView<T> . By format, I mean auto-formatting using the CTRL + K + D key combination. When I press the format combination, the namespace and class name get lowercased and all references to Model appear to break. This only occurs on GlassViews... traditional Views using a @model declaration appear to be unaffected. Any

Sitecore MVC Controller and Forms - ActionResult not rendering Layout on postback

时光总嘲笑我的痴心妄想 提交于 2019-12-13 04:06:12
问题 Sitecore 7.1v1, most recent Glass Mapper, MVC4. When we submit the form POST, we get no layout with the return View. I'd prefer not to have to redirect to another page since this is supposed to be a wizard-like experience. This is also lightweight enough not to require Ajax, although we could use it as a last resort. I can't find who to make sure that while returning the View that we get the layout as well. I'm new to Sitecore MVC and pretty new at MVC in general. The PageBase that's

How to enable VersionCountDisabler for Glass Mapper in Sitecore for SitecoreQuery and SitecoreChildren attributes

拈花ヽ惹草 提交于 2019-12-12 06:58:22
问题 The glass mapper will return null object or (no items) for SitecoreQuery and SitecoreChildren attribute that are placed on the GlassModels. These attributes don't take any such parameter where I can specify them to return items if they don't exist in the the context lanaguge. The items e.g. exist in EN but don't exist in en-ES. I need to put a lot of null check in my views to avoid Null exception and makes the views or controller very messy. It is lot of boiler plate code that one has to

Glass Mapper t4 null or empty string

心不动则不痛 提交于 2019-12-12 04:56:55
问题 I'm trying to setup Glass Mapper to generate my Sitecore items. I've followed every tutorial I could find, but receive this error when attempting to generate the code: "Loading the include file 'Helpers.tt' returned a null or empty string. The transformation will not be run." A file is generated but repeats the word "ErrorGeneratingOutput" over and over. Screenshots: 回答1: As well as what Ehab has suggested, you may also have to remove the empty line at the end of GlassV3Header.tt otherwise