Skip to main content
Commonmark migration
Source Link

Use the rendering datasource

I would recommend not tying an item directly to a rendering, in code, in the rendering. The way that Sitecore MVC works is that the context for @Html.Sitecore() is determined by the datasource being set or not.

If datasouce not set, @Html.Sitecore() = current page/item

 

If datasouce set, @Html.Sitecore() = datasource item

How to do it

I would recommend that you set the Title the way you currently are.

<div class="event__title">
    @Html.Sitecore().Field("Title")
</div>

Then set the datasource in the rendering itself. Not on the rendering in the page, but in the actual rendering item. This "hard codes" the datasource to the rendering. But it doesn't take a deployment to change it.

enter image description here

Override it

You can override the item by setting the datasource in the traditional way.

Use the rendering datasource

I would recommend not tying an item directly to a rendering, in code, in the rendering. The way that Sitecore MVC works is that the context for @Html.Sitecore() is determined by the datasource being set or not.

If datasouce not set, @Html.Sitecore() = current page/item

 

If datasouce set, @Html.Sitecore() = datasource item

How to do it

I would recommend that you set the Title the way you currently are.

<div class="event__title">
    @Html.Sitecore().Field("Title")
</div>

Then set the datasource in the rendering itself. Not on the rendering in the page, but in the actual rendering item. This "hard codes" the datasource to the rendering. But it doesn't take a deployment to change it.

enter image description here

Override it

You can override the item by setting the datasource in the traditional way.

Use the rendering datasource

I would recommend not tying an item directly to a rendering, in code, in the rendering. The way that Sitecore MVC works is that the context for @Html.Sitecore() is determined by the datasource being set or not.

If datasouce not set, @Html.Sitecore() = current page/item

If datasouce set, @Html.Sitecore() = datasource item

How to do it

I would recommend that you set the Title the way you currently are.

<div class="event__title">
    @Html.Sitecore().Field("Title")
</div>

Then set the datasource in the rendering itself. Not on the rendering in the page, but in the actual rendering item. This "hard codes" the datasource to the rendering. But it doesn't take a deployment to change it.

enter image description here

Override it

You can override the item by setting the datasource in the traditional way.

added 17 characters in body
Source Link
Chris Auer
  • 13.2k
  • 1
  • 30
  • 87

Use the rendering datasource

I would recommend not tying an item directly to a rendering, in code, in the rendering. The way that Sitecore MVC works is that the context for @Html.Sitecore() is determined by the datasource being set or not.

If datasouce not set, @Html.Sitecore() = current page/item

If datasouce set, @Html.Sitecore() = datasource item

How to do it

I would recommend that you set the Title the way you currently are.

<div class="event__title">
    @Html.Sitecore().Field("Title")
</div>

Then set the datasource in the rendering itself. Not on the rendering in the page, but in the actual rendering item. This "hard codes" the datasource to the rendering. But it doesn't take a deployment to change it.

enter image description here

Override it

You can override the item by setting the datasource in the traditional way.

Use the rendering datasource

I would recommend not tying an item directly to a rendering, in code, in the rendering. The way that Sitecore MVC works is that the context for @Html.Sitecore() is determined by the datasource.

If datasouce not set, @Html.Sitecore() = current page/item

If datasouce set, @Html.Sitecore() = datasource item

How to do it

I would recommend that you set the Title the way you currently are.

<div class="event__title">
    @Html.Sitecore().Field("Title")
</div>

Then set the datasource in the rendering itself. Not on the rendering in the page, but in the actual rendering item. This "hard codes" the datasource to the rendering. But it doesn't take a deployment to change it.

enter image description here

Override it

You can override the item by setting the datasource in the traditional way.

Use the rendering datasource

I would recommend not tying an item directly to a rendering, in code, in the rendering. The way that Sitecore MVC works is that the context for @Html.Sitecore() is determined by the datasource being set or not.

If datasouce not set, @Html.Sitecore() = current page/item

If datasouce set, @Html.Sitecore() = datasource item

How to do it

I would recommend that you set the Title the way you currently are.

<div class="event__title">
    @Html.Sitecore().Field("Title")
</div>

Then set the datasource in the rendering itself. Not on the rendering in the page, but in the actual rendering item. This "hard codes" the datasource to the rendering. But it doesn't take a deployment to change it.

enter image description here

Override it

You can override the item by setting the datasource in the traditional way.

Source Link
Chris Auer
  • 13.2k
  • 1
  • 30
  • 87

Use the rendering datasource

I would recommend not tying an item directly to a rendering, in code, in the rendering. The way that Sitecore MVC works is that the context for @Html.Sitecore() is determined by the datasource.

If datasouce not set, @Html.Sitecore() = current page/item

If datasouce set, @Html.Sitecore() = datasource item

How to do it

I would recommend that you set the Title the way you currently are.

<div class="event__title">
    @Html.Sitecore().Field("Title")
</div>

Then set the datasource in the rendering itself. Not on the rendering in the page, but in the actual rendering item. This "hard codes" the datasource to the rendering. But it doesn't take a deployment to change it.

enter image description here

Override it

You can override the item by setting the datasource in the traditional way.