26
votes
Accepted
Editable Sitecore fields with Glass
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)
}
24
votes
Accepted
C# MVC razor view - HtmlHelper does not contain a definition for 'Sitecore'
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 ...
12
votes
Accepted
Glass BeginRenderLink not showing text node
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. ...
6
votes
Is there a way to supress rendering width and height attribs using Fortis Image.Render?
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 ...
6
votes
Accepted
How to Render @Html.Sitecore().Field using custom Model Item in Sitecore MVC
@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 ...
6
votes
Accepted
Sitecore instance is very slow after deployment in Azure Paas
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 ...
4
votes
Accepted
Custom View Engine for Razor View Helix-type default paths
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
...
3
votes
Accepted
Sitecore Helper to render SXA Component inside cshtml
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 - ...
3
votes
Put Sitecore component on page based on QueryString
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 ...
2
votes
Accepted
Put Sitecore component on page based on QueryString
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"];
...
2
votes
How to Render @Html.Sitecore().Field using custom Model Item in Sitecore MVC
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 ...
2
votes
Accepted
How to cache bust CSS and JS assets in Sitecore Helix
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 ...
1
vote
Search Results caching
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 ...
1
vote
Accepted
Item preview fails with "Section or group name 'system.web.webPages.razor' is already defined"
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....
1
vote
C# MVC razor view - HtmlHelper does not contain a definition for 'Sitecore'
I also encountered the same thing. I grabbed the web.config from the habitat demo solution, one of the web.config from the views there and it works fine.
Here's the full web.config.
<?xml ...
1
vote
C# MVC razor view - HtmlHelper does not contain a definition for 'Sitecore'
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....
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
razor × 16experience-editor × 3
glass-mapper × 3
mvc × 3
sxa × 2
presentation × 2
rendering-parameters × 2
sitecore-client × 1
configuration × 1
paas × 1
helix × 1
coveo × 1
deployment × 1
links × 1
link-manager × 1
renderfield × 1
fortis × 1