How to Connect controller rendering with Interface Template
Clash Royale CLAN TAG#URR8PPP
up vote
2
down vote
favorite
I am trying to create a simple Image controller Rendering and I don't wnat to add the template Interface to my Page Type, because I want to add the image dynamicaly to my site.
So here my "problems" begin.
I've created a simple Controllerrendering with a viewmodel
public class PageImageViewModel
public HtmlString PageImage get; set;
as simple Controller call to my ModelBuilder
public ActionResult PageImage()
return View(PageImageModelBuilder.GetPageImageViewModel(RenderingContext.Current.ContextItem));
and the modelbuilder
public PageImageViewModel GetPageImageViewModel(Item currentItem)
var model = new PageImageViewModel();
model.PageImage = new HtmlString(FieldRenderer.Render(currentItem, Templates.PageImage.Fields.Image_FieldName));
return model;
and the view
@using Bazar.Feature.PageContent
@model Bazar.Feature.PageContent.Models.Models.PageImageViewModel
<div class="">
<p>Hallo Welt</p>
@Model.PageImage
</div>
thats the codeside I think that should work.
and now the sitecore elments
- I've created a Interface Template for my _PageImage
- I've created the Controller rendering
- And I've tried to add this new control to my "Home" view where I've some dynamic placeholders but I don't get the modal where I can choose what Image I want to see.
- try to add the controller rendering to my page
- but after that no image selection is opened and the final layout looks like
and I can't edit or select the Image
so far I understand my Problem is the controller rendering has no connection to my Interface Template _PageImage but I don't understand how to get this "connection"?
helix controller
add a comment |Â
up vote
2
down vote
favorite
I am trying to create a simple Image controller Rendering and I don't wnat to add the template Interface to my Page Type, because I want to add the image dynamicaly to my site.
So here my "problems" begin.
I've created a simple Controllerrendering with a viewmodel
public class PageImageViewModel
public HtmlString PageImage get; set;
as simple Controller call to my ModelBuilder
public ActionResult PageImage()
return View(PageImageModelBuilder.GetPageImageViewModel(RenderingContext.Current.ContextItem));
and the modelbuilder
public PageImageViewModel GetPageImageViewModel(Item currentItem)
var model = new PageImageViewModel();
model.PageImage = new HtmlString(FieldRenderer.Render(currentItem, Templates.PageImage.Fields.Image_FieldName));
return model;
and the view
@using Bazar.Feature.PageContent
@model Bazar.Feature.PageContent.Models.Models.PageImageViewModel
<div class="">
<p>Hallo Welt</p>
@Model.PageImage
</div>
thats the codeside I think that should work.
and now the sitecore elments
- I've created a Interface Template for my _PageImage
- I've created the Controller rendering
- And I've tried to add this new control to my "Home" view where I've some dynamic placeholders but I don't get the modal where I can choose what Image I want to see.
- try to add the controller rendering to my page
- but after that no image selection is opened and the final layout looks like
and I can't edit or select the Image
so far I understand my Problem is the controller rendering has no connection to my Interface Template _PageImage but I don't understand how to get this "connection"?
helix controller
add a comment |Â
up vote
2
down vote
favorite
up vote
2
down vote
favorite
I am trying to create a simple Image controller Rendering and I don't wnat to add the template Interface to my Page Type, because I want to add the image dynamicaly to my site.
So here my "problems" begin.
I've created a simple Controllerrendering with a viewmodel
public class PageImageViewModel
public HtmlString PageImage get; set;
as simple Controller call to my ModelBuilder
public ActionResult PageImage()
return View(PageImageModelBuilder.GetPageImageViewModel(RenderingContext.Current.ContextItem));
and the modelbuilder
public PageImageViewModel GetPageImageViewModel(Item currentItem)
var model = new PageImageViewModel();
model.PageImage = new HtmlString(FieldRenderer.Render(currentItem, Templates.PageImage.Fields.Image_FieldName));
return model;
and the view
@using Bazar.Feature.PageContent
@model Bazar.Feature.PageContent.Models.Models.PageImageViewModel
<div class="">
<p>Hallo Welt</p>
@Model.PageImage
</div>
thats the codeside I think that should work.
and now the sitecore elments
- I've created a Interface Template for my _PageImage
- I've created the Controller rendering
- And I've tried to add this new control to my "Home" view where I've some dynamic placeholders but I don't get the modal where I can choose what Image I want to see.
- try to add the controller rendering to my page
- but after that no image selection is opened and the final layout looks like
and I can't edit or select the Image
so far I understand my Problem is the controller rendering has no connection to my Interface Template _PageImage but I don't understand how to get this "connection"?
helix controller
I am trying to create a simple Image controller Rendering and I don't wnat to add the template Interface to my Page Type, because I want to add the image dynamicaly to my site.
So here my "problems" begin.
I've created a simple Controllerrendering with a viewmodel
public class PageImageViewModel
public HtmlString PageImage get; set;
as simple Controller call to my ModelBuilder
public ActionResult PageImage()
return View(PageImageModelBuilder.GetPageImageViewModel(RenderingContext.Current.ContextItem));
and the modelbuilder
public PageImageViewModel GetPageImageViewModel(Item currentItem)
var model = new PageImageViewModel();
model.PageImage = new HtmlString(FieldRenderer.Render(currentItem, Templates.PageImage.Fields.Image_FieldName));
return model;
and the view
@using Bazar.Feature.PageContent
@model Bazar.Feature.PageContent.Models.Models.PageImageViewModel
<div class="">
<p>Hallo Welt</p>
@Model.PageImage
</div>
thats the codeside I think that should work.
and now the sitecore elments
- I've created a Interface Template for my _PageImage
- I've created the Controller rendering
- And I've tried to add this new control to my "Home" view where I've some dynamic placeholders but I don't get the modal where I can choose what Image I want to see.
- try to add the controller rendering to my page
- but after that no image selection is opened and the final layout looks like
and I can't edit or select the Image
so far I understand my Problem is the controller rendering has no connection to my Interface Template _PageImage but I don't understand how to get this "connection"?
helix controller
helix controller
edited 2 hours ago
asked 4 hours ago
squadwuschel
2959
2959
add a comment |Â
add a comment |Â
1 Answer
1
active
oldest
votes
up vote
3
down vote
The simple fix
You need to specify a template in the Datasource Template
field of your controller rendering. This is the field that tells Sitecore to prompt an editor to select a data source when adding a rendering.
A cool feature
Sitecore will take template inheritance into account when allowing you to select data sources, which means that you'll be able to select any item that has a base template of the one you select here (e.g. _PageImage
).
Another recommendation
Additionally, it's good practice to specify the location under which data sources can be found by putting that path in the Datasource Location
field:
add a comment |Â
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
3
down vote
The simple fix
You need to specify a template in the Datasource Template
field of your controller rendering. This is the field that tells Sitecore to prompt an editor to select a data source when adding a rendering.
A cool feature
Sitecore will take template inheritance into account when allowing you to select data sources, which means that you'll be able to select any item that has a base template of the one you select here (e.g. _PageImage
).
Another recommendation
Additionally, it's good practice to specify the location under which data sources can be found by putting that path in the Datasource Location
field:
add a comment |Â
up vote
3
down vote
The simple fix
You need to specify a template in the Datasource Template
field of your controller rendering. This is the field that tells Sitecore to prompt an editor to select a data source when adding a rendering.
A cool feature
Sitecore will take template inheritance into account when allowing you to select data sources, which means that you'll be able to select any item that has a base template of the one you select here (e.g. _PageImage
).
Another recommendation
Additionally, it's good practice to specify the location under which data sources can be found by putting that path in the Datasource Location
field:
add a comment |Â
up vote
3
down vote
up vote
3
down vote
The simple fix
You need to specify a template in the Datasource Template
field of your controller rendering. This is the field that tells Sitecore to prompt an editor to select a data source when adding a rendering.
A cool feature
Sitecore will take template inheritance into account when allowing you to select data sources, which means that you'll be able to select any item that has a base template of the one you select here (e.g. _PageImage
).
Another recommendation
Additionally, it's good practice to specify the location under which data sources can be found by putting that path in the Datasource Location
field:
The simple fix
You need to specify a template in the Datasource Template
field of your controller rendering. This is the field that tells Sitecore to prompt an editor to select a data source when adding a rendering.
A cool feature
Sitecore will take template inheritance into account when allowing you to select data sources, which means that you'll be able to select any item that has a base template of the one you select here (e.g. _PageImage
).
Another recommendation
Additionally, it's good practice to specify the location under which data sources can be found by putting that path in the Datasource Location
field:
edited 20 mins ago
answered 2 hours ago
Dan Sinclair
414312
414312
add a comment |Â
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fsitecore.stackexchange.com%2fquestions%2f14385%2fhow-to-connect-controller-rendering-with-interface-template%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password