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.
episerver-10
add a comment |
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.
episerver-10
add a comment |
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.
episerver-10
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
episerver-10
asked Nov 20 at 7:21
Titiksha Mahimker
62
62
add a comment |
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
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.
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
Required, but never shown
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
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
Required, but never shown
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
Required, but never shown
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
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