Episerver CMS 10











up vote
0
down vote

favorite












I am currently using Episerver CMS 10.
I have 2 pagetypes as follows :
1. Standard Page Type.
2. Inherit standard Page Type



In Standard Page type i have a property Keyword which has values in episerver content .
I have created the property keyword in Inherit standard Page and inherited the values of Standard page as below :



[Display(GroupName = GroupNames.MetaData, Order = 1)]



    [Editable(false, AllowInitialValue = true)]
public virtual string Keyword
{
get
{
if (myMaster != null)
{
return myMaster.GetPropertyValue(p =>p.MetaData.Keywords);

}


return string.Empty;
}
set
{
this.SetPropertyValue(p => p.Keyword, value);
}
}


but as the values of keyword were not visible in Inheritstandardpagetype I have created IInitialization module



   public void Initialize(InitializationEngine context)
{
//Add initialization logic, this method is called once after CMS has been initialized
var contentEvents = ServiceLocator.Current.GetInstance<IContentEvents>();
contentEvents.CreatedContent += InheritedMetadataValues;
//InheritEvents.UpdatedInheritor += InheritEvents_UpdatedInheritor;
}

private void InheritedMetadataValues(object sender, ContentEventArgs e)
{
PopulateMetadata(e);
}
private void PopulateMetadata(ContentEventArgs e)
{
var inheritedPage = e.Content as InheritStandardPageType;
if (inheritedPage != null)
{
var srvcLoc = ServiceLocator.Current.GetInstance<IContentRepository>();
var contentReference = new ContentReference();
contentReference = inheritedPage.MyMasterReference;

//var contentClone = inheritedPage.CreateWritableClone() as InheritStandardPageType;
MasterStandardPageType myMaster = ServiceLocator.Current.GetInstance<IContentRepository>().Get<MasterStandardPageType>(inheritedPage.MyMasterReference);
//inheritedPage.Keyword = myMaster.MetaData.Keywords;

//MasterStandardPageType myMaster => contentReference != null ? ServiceLocator.Current.GetInstance<IContentRepository>().Get<MasterStandardPageType>(MyMasterReference) : null;
inheritedPage.Keyword = myMaster.MetaData.Keywords;
inheritedPage.Desciption = myMaster.MetaData.Description;
inheritedPage.Author = myMaster.MetaData.Author;
/*ontentClone.GlobalMetaData = myMaster.MetaData;*/
srvcLoc.Save(inheritedPage, SaveAction.ForceCurrentVersion, EPiServer.Security.AccessLevel.NoAccess);
}
}


public void Uninitialize(InitializationEngine context)
{
var contentEvents = ServiceLocator.Current.GetInstance<IContentEvents>();
contentEvents.SavedContent -= InheritedMetadataValues;
}


But the problem I am facing is when we add some keyword in the standard page and publish it again then only the child page is updated and also the child page status is updated .
I wanted the child page should be updated automatically if the master page keyword has values.










share|improve this question


























    up vote
    0
    down vote

    favorite












    I am currently using Episerver CMS 10.
    I have 2 pagetypes as follows :
    1. Standard Page Type.
    2. Inherit standard Page Type



    In Standard Page type i have a property Keyword which has values in episerver content .
    I have created the property keyword in Inherit standard Page and inherited the values of Standard page as below :



    [Display(GroupName = GroupNames.MetaData, Order = 1)]



        [Editable(false, AllowInitialValue = true)]
    public virtual string Keyword
    {
    get
    {
    if (myMaster != null)
    {
    return myMaster.GetPropertyValue(p =>p.MetaData.Keywords);

    }


    return string.Empty;
    }
    set
    {
    this.SetPropertyValue(p => p.Keyword, value);
    }
    }


    but as the values of keyword were not visible in Inheritstandardpagetype I have created IInitialization module



       public void Initialize(InitializationEngine context)
    {
    //Add initialization logic, this method is called once after CMS has been initialized
    var contentEvents = ServiceLocator.Current.GetInstance<IContentEvents>();
    contentEvents.CreatedContent += InheritedMetadataValues;
    //InheritEvents.UpdatedInheritor += InheritEvents_UpdatedInheritor;
    }

    private void InheritedMetadataValues(object sender, ContentEventArgs e)
    {
    PopulateMetadata(e);
    }
    private void PopulateMetadata(ContentEventArgs e)
    {
    var inheritedPage = e.Content as InheritStandardPageType;
    if (inheritedPage != null)
    {
    var srvcLoc = ServiceLocator.Current.GetInstance<IContentRepository>();
    var contentReference = new ContentReference();
    contentReference = inheritedPage.MyMasterReference;

    //var contentClone = inheritedPage.CreateWritableClone() as InheritStandardPageType;
    MasterStandardPageType myMaster = ServiceLocator.Current.GetInstance<IContentRepository>().Get<MasterStandardPageType>(inheritedPage.MyMasterReference);
    //inheritedPage.Keyword = myMaster.MetaData.Keywords;

    //MasterStandardPageType myMaster => contentReference != null ? ServiceLocator.Current.GetInstance<IContentRepository>().Get<MasterStandardPageType>(MyMasterReference) : null;
    inheritedPage.Keyword = myMaster.MetaData.Keywords;
    inheritedPage.Desciption = myMaster.MetaData.Description;
    inheritedPage.Author = myMaster.MetaData.Author;
    /*ontentClone.GlobalMetaData = myMaster.MetaData;*/
    srvcLoc.Save(inheritedPage, SaveAction.ForceCurrentVersion, EPiServer.Security.AccessLevel.NoAccess);
    }
    }


    public void Uninitialize(InitializationEngine context)
    {
    var contentEvents = ServiceLocator.Current.GetInstance<IContentEvents>();
    contentEvents.SavedContent -= InheritedMetadataValues;
    }


    But the problem I am facing is when we add some keyword in the standard page and publish it again then only the child page is updated and also the child page status is updated .
    I wanted the child page should be updated automatically if the master page keyword has values.










    share|improve this question
























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      I am currently using Episerver CMS 10.
      I have 2 pagetypes as follows :
      1. Standard Page Type.
      2. Inherit standard Page Type



      In Standard Page type i have a property Keyword which has values in episerver content .
      I have created the property keyword in Inherit standard Page and inherited the values of Standard page as below :



      [Display(GroupName = GroupNames.MetaData, Order = 1)]



          [Editable(false, AllowInitialValue = true)]
      public virtual string Keyword
      {
      get
      {
      if (myMaster != null)
      {
      return myMaster.GetPropertyValue(p =>p.MetaData.Keywords);

      }


      return string.Empty;
      }
      set
      {
      this.SetPropertyValue(p => p.Keyword, value);
      }
      }


      but as the values of keyword were not visible in Inheritstandardpagetype I have created IInitialization module



         public void Initialize(InitializationEngine context)
      {
      //Add initialization logic, this method is called once after CMS has been initialized
      var contentEvents = ServiceLocator.Current.GetInstance<IContentEvents>();
      contentEvents.CreatedContent += InheritedMetadataValues;
      //InheritEvents.UpdatedInheritor += InheritEvents_UpdatedInheritor;
      }

      private void InheritedMetadataValues(object sender, ContentEventArgs e)
      {
      PopulateMetadata(e);
      }
      private void PopulateMetadata(ContentEventArgs e)
      {
      var inheritedPage = e.Content as InheritStandardPageType;
      if (inheritedPage != null)
      {
      var srvcLoc = ServiceLocator.Current.GetInstance<IContentRepository>();
      var contentReference = new ContentReference();
      contentReference = inheritedPage.MyMasterReference;

      //var contentClone = inheritedPage.CreateWritableClone() as InheritStandardPageType;
      MasterStandardPageType myMaster = ServiceLocator.Current.GetInstance<IContentRepository>().Get<MasterStandardPageType>(inheritedPage.MyMasterReference);
      //inheritedPage.Keyword = myMaster.MetaData.Keywords;

      //MasterStandardPageType myMaster => contentReference != null ? ServiceLocator.Current.GetInstance<IContentRepository>().Get<MasterStandardPageType>(MyMasterReference) : null;
      inheritedPage.Keyword = myMaster.MetaData.Keywords;
      inheritedPage.Desciption = myMaster.MetaData.Description;
      inheritedPage.Author = myMaster.MetaData.Author;
      /*ontentClone.GlobalMetaData = myMaster.MetaData;*/
      srvcLoc.Save(inheritedPage, SaveAction.ForceCurrentVersion, EPiServer.Security.AccessLevel.NoAccess);
      }
      }


      public void Uninitialize(InitializationEngine context)
      {
      var contentEvents = ServiceLocator.Current.GetInstance<IContentEvents>();
      contentEvents.SavedContent -= InheritedMetadataValues;
      }


      But the problem I am facing is when we add some keyword in the standard page and publish it again then only the child page is updated and also the child page status is updated .
      I wanted the child page should be updated automatically if the master page keyword has values.










      share|improve this question













      I am currently using Episerver CMS 10.
      I have 2 pagetypes as follows :
      1. Standard Page Type.
      2. Inherit standard Page Type



      In Standard Page type i have a property Keyword which has values in episerver content .
      I have created the property keyword in Inherit standard Page and inherited the values of Standard page as below :



      [Display(GroupName = GroupNames.MetaData, Order = 1)]



          [Editable(false, AllowInitialValue = true)]
      public virtual string Keyword
      {
      get
      {
      if (myMaster != null)
      {
      return myMaster.GetPropertyValue(p =>p.MetaData.Keywords);

      }


      return string.Empty;
      }
      set
      {
      this.SetPropertyValue(p => p.Keyword, value);
      }
      }


      but as the values of keyword were not visible in Inheritstandardpagetype I have created IInitialization module



         public void Initialize(InitializationEngine context)
      {
      //Add initialization logic, this method is called once after CMS has been initialized
      var contentEvents = ServiceLocator.Current.GetInstance<IContentEvents>();
      contentEvents.CreatedContent += InheritedMetadataValues;
      //InheritEvents.UpdatedInheritor += InheritEvents_UpdatedInheritor;
      }

      private void InheritedMetadataValues(object sender, ContentEventArgs e)
      {
      PopulateMetadata(e);
      }
      private void PopulateMetadata(ContentEventArgs e)
      {
      var inheritedPage = e.Content as InheritStandardPageType;
      if (inheritedPage != null)
      {
      var srvcLoc = ServiceLocator.Current.GetInstance<IContentRepository>();
      var contentReference = new ContentReference();
      contentReference = inheritedPage.MyMasterReference;

      //var contentClone = inheritedPage.CreateWritableClone() as InheritStandardPageType;
      MasterStandardPageType myMaster = ServiceLocator.Current.GetInstance<IContentRepository>().Get<MasterStandardPageType>(inheritedPage.MyMasterReference);
      //inheritedPage.Keyword = myMaster.MetaData.Keywords;

      //MasterStandardPageType myMaster => contentReference != null ? ServiceLocator.Current.GetInstance<IContentRepository>().Get<MasterStandardPageType>(MyMasterReference) : null;
      inheritedPage.Keyword = myMaster.MetaData.Keywords;
      inheritedPage.Desciption = myMaster.MetaData.Description;
      inheritedPage.Author = myMaster.MetaData.Author;
      /*ontentClone.GlobalMetaData = myMaster.MetaData;*/
      srvcLoc.Save(inheritedPage, SaveAction.ForceCurrentVersion, EPiServer.Security.AccessLevel.NoAccess);
      }
      }


      public void Uninitialize(InitializationEngine context)
      {
      var contentEvents = ServiceLocator.Current.GetInstance<IContentEvents>();
      contentEvents.SavedContent -= InheritedMetadataValues;
      }


      But the problem I am facing is when we add some keyword in the standard page and publish it again then only the child page is updated and also the child page status is updated .
      I wanted the child page should be updated automatically if the master page keyword has values.







      episerver-10






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 20 at 7:21









      Titiksha Mahimker

      62




      62





























          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          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: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














          draft saved

          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53388071%2fepiserver-cms-10%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown






























          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          draft saved

          draft discarded




















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid



          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.


          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53388071%2fepiserver-cms-10%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          404 Error Contact Form 7 ajax form submitting

          How to know if a Active Directory user can login interactively

          Refactoring coordinates for Minecraft Pi buildings written in Python