Hot answers tagged

25

This should give you what you want: @using (Html.Glass().BeginRenderLink(Model, m => m.MyLinkField, null, true) { @Html.Glass().RenderImage(Model, m => m.MyImageField, null, true) }


20

There's a web.config that has Sitecore references that should exist in the /Views that is probably not right. This can be a common occurrence if using a new .NET MVC Project in Visual Studio and it accidently overwrites the Sitecore version. You can grab the web.config from the Sitecore Vanilla Zip file to compare. <system.web.webPages.razor> ...


10

The fact that BeginRenderLink does not render link text inside the <a> tag is not bug. As Glass Mapper documentation says, BeginRenderLink is not really for displaying the default link text. You should use it if you want to add something custom inside your link. The BeginRenderLink can be used to render a link that should contain multiple HTML ...


6

You can't do that out of the box with Fortis because under the hood it is just using the standard Sitecore Field Renderer. This is what is adding the width and height attributes. There is a nice solution here that adds a new processor to the RenderField pipeline that strips out those attributes if a parameter called responsive is added. With Fortis you ...


6

With regards to the initial very large time, what you're most likely hitting is that Sitecore can max out the Azure SQL on startup to fill the prefetch cache - see Sitecore Knowledge Base Article 290593 The solution is to disable the prefetch cache by using the configuration file on the attached knowledge base article. According to Sitecore: The Sitecore ...


5

@Html.Sitecore().Field only works with real items and it sounds like Model.ArticleItem is not a real Sitecore Item. What you want to do is render the Sitecore field as HTML in your model and render that. // get your sitecore item var item = RenderingContext.Current.ContextItem; // get the sitecore editor html (will only render the data if not in edit ...


4

Yes, you can create your custom View Engine to resolve relative paths based on the assembly name. So, following this guide: https://weblogs.asp.net/imranbaloch/view-engine-with-dynamic-view-location You can add a path like that: "~/Views/%feature/{0}.cshtml" And override the following methods: protected override IView CreatePartialView(...


3

You have 2 main options: Use a placeholder In your razor view, just add a placeholder, then in the Experience Editor, your marketers/editors can add the Social Media Share module to that. Pros - its nice and easy, give flexibility too if you wanted to add anything else. Cons - the editors have to remember to add the component every time. Render the ...


3

I think your title is a little different than what you want to really achieve. But you could build a Controller Rendering, that looks at the current pages Querystring, to get it's Id, and use that to return data to your view. public ActionResult Render() { string featBlogPost = Request.QueryString["featpost"]; if (ID.TryParse(featBlogPost, ref ID ...


2

You may need to statically add your rendering inside the container rendering, something like this would work inside the container rendering @{ var featBlogPost = Request.QueryString["featpost"]; var isFeatBlogPost = Sitecore.Data.ID.IsID(featBlogPost); if(isFeatBlogPost){ var featBlogPostID = Sitecore.Data.ID.Parse(featBlogPost); ...


2

In your controller (or service), you could also add the Sitecore.Items.Item on the view model that you send to your view and then use that item to render the content and Experience Editor functionality: Controller/service var contextItem = RenderingContext.Current.ContextItem; var articleItem = // get article item from multilist on contextItem; var ...


1

There are many methods, but since we build Helix projects with gulp one option is to leverage gulp to perform this action automatically. At the top of your your gulpfile.js, require these modules: var uniqId = require('uniqid'); var cacheBust = require('gulp-cache-bust'); Install these npm modules. Then build the function: var reviseAssets = function() ...


1

Your "if" statement mentions Creative Exchange: if (WebUtil.GetQueryString(Sitecore.XA.Feature.Search.Constants.CreativeExchangeExport) != "true") This tells me that the else part will be executed when the Creative Exchange parameter is in the querystring. That is why you will never see that part in the actual website - you'll always get the first (if) ...


1

Coveo for Sitecore 4.1 came with Web.configs that referenced System.Web.WebPages.Razor V2.0.0. My project uses 3.0.0. I had to update the version in the following files to 3.0.0: Views/Coveo/Web.config Views/Coveo Hive/Web.config layouts/Coveo Hive Coveo/Hive/templates


1

I think you are missing Sitecore from your Views web.config. You web.config in the /views folder should look like this <system.web.webPages.razor> <host factoryType="System.Web.Mvc.MvcWebRazorHostFactory, System.Web.Mvc, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35" /> <pages pageBaseType="System.Web.Mvc....


Only top voted, non community-wiki answers of a minimum length are eligible