How to Connect controller rendering with Interface Template

The name of the pictureThe name of the pictureThe name of the pictureClash 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

enter image description here



enter image description here



  • 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

enter image description here



  • but after that no image selection is opened and the final layout looks like

enter image description here



  • and I can't edit or select the Image
    enter image description here


  • 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"?










share|improve this question



























    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

    enter image description here



    enter image description here



    • 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

    enter image description here



    • but after that no image selection is opened and the final layout looks like

    enter image description here



    • and I can't edit or select the Image
      enter image description here


    • 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"?










    share|improve this question

























      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

      enter image description here



      enter image description here



      • 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

      enter image description here



      • but after that no image selection is opened and the final layout looks like

      enter image description here



      • and I can't edit or select the Image
        enter image description here


      • 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"?










      share|improve this question















      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

      enter image description here



      enter image description here



      • 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

      enter image description here



      • but after that no image selection is opened and the final layout looks like

      enter image description here



      • and I can't edit or select the Image
        enter image description here


      • 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






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 2 hours ago

























      asked 4 hours ago









      squadwuschel

      2959




      2959




















          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.



          Image of Datasource Location and Datasource Template fields



          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:



          enter image description here






          share|improve this answer






















            Your Answer







            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "664"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            convertImagesToLinks: false,
            noModals: false,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: null,
            bindNavPrevention: true,
            postfix: "",
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













             

            draft saved


            draft discarded


















            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






























            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.



            Image of Datasource Location and Datasource Template fields



            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:



            enter image description here






            share|improve this answer


























              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.



              Image of Datasource Location and Datasource Template fields



              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:



              enter image description here






              share|improve this answer
























                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.



                Image of Datasource Location and Datasource Template fields



                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:



                enter image description here






                share|improve this answer














                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.



                Image of Datasource Location and Datasource Template fields



                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:



                enter image description here







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited 20 mins ago

























                answered 2 hours ago









                Dan Sinclair

                414312




                414312



























                     

                    draft saved


                    draft discarded















































                     


                    draft saved


                    draft discarded














                    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













































































                    Comments

                    Popular posts from this blog

                    What does second last employer means? [closed]

                    Installing NextGIS Connect into QGIS 3?

                    One-line joke