How to prevent EPiServer to inherit categories to childrenpages
by Rizo on jan.14, 2010, under Developing
One of the pages I’ve been working on uses EPiServers categories a lot. But the annoying part with EPiServers categories is the way they inherit down to all children, which leads to the problem that categories can be deleted without someone meaning too. e.g you create a page called ”Books” and you have a control that creates a category using the pagename. Below ”Books” you’ll add all the books you want, but all those books will get the category ”books” aswell. But to prevent dead categories, you might want to make a check that once you delete a page, you’ll also delete the category. Then, when deleting a childpage, you’ll also delete the real category, since the childpage also had this category. There are of course ways to prevent this but this can easily be forgotten and cause future problems. It will also mess up search results that uses categories to find information and so on.
Enough with examples, let’s get on the easy solution.
[sourcecode language=’c#’]
EPiServer.DataFactory.Instance.PublishingPage += CreateCategory;
EPiServer.DataFactory.Instance.SavedPage += CreateCategory;
EPiServer.DataFactory.Instance.SavingPage += CreateCategory;
EPiServer.DataFactory.Instance.CreatingPage += CreateCategory;
static void CreateCategory(object sender, EPiServer.PageEventArgs e)
{
if (!ValidPage(e.Page.PageTypeID))
{
e.Page.Property[”PageCategory”].Value = string.Empty;
}
}
[/sourcecode]
Basicly, you’ll call the method ”CreateCategory” whenever you create, save or publish a page. Then use a method to determinate if the pagetypeid of the page you are creating is a validpage (i.e you don’t want these pages to inherit categories) and then just give it a string.Emtpy as PageCategory value. Whatever the situation, just make a method to check if you want the page to inherit the category or not, then use the code above.
Hope this helps
3 Comments for this entry
21 Trackbacks / Pingbacks for this entry
-
https://www.heraldnet.com/reviews/phenq-reviews-is-it-legit-update/
oktober 10th, 2023 on 11:43… [Trackback]
[…] Find More Information here to that Topic: from-rizo.se/how-to-prevent-episerver-to-inherit-categories-to-childrenpages/ […]
-
เกมสล็อต
november 12th, 2023 on 04:52… [Trackback]
[…] Read More on to that Topic: from-rizo.se/how-to-prevent-episerver-to-inherit-categories-to-childrenpages/ […]
-
EV Charger
december 28th, 2023 on 01:43… [Trackback]
[…] Here you will find 86709 additional Information to that Topic: from-rizo.se/how-to-prevent-episerver-to-inherit-categories-to-childrenpages/ […]
-
buy rifles online
februari 18th, 2024 on 03:50… [Trackback]
[…] Find More on to that Topic: from-rizo.se/how-to-prevent-episerver-to-inherit-categories-to-childrenpages/ […]
-
พรมปูพื้นรถยนต์ Changan Deepal L07
februari 25th, 2024 on 00:44… [Trackback]
[…] Read More on on that Topic: from-rizo.se/how-to-prevent-episerver-to-inherit-categories-to-childrenpages/ […]
-
https://thetablalibrary.com/contribute/
mars 1st, 2024 on 00:27… [Trackback]
[…] There you will find 46435 more Information on that Topic: from-rizo.se/how-to-prevent-episerver-to-inherit-categories-to-childrenpages/ […]
-
บุญมี สล็อต
mars 12th, 2024 on 02:25… [Trackback]
[…] Find More on that Topic: from-rizo.se/how-to-prevent-episerver-to-inherit-categories-to-childrenpages/ […]
-
citas lesbianas málaga
mars 17th, 2024 on 16:45… [Trackback]
[…] Information to that Topic: from-rizo.se/how-to-prevent-episerver-to-inherit-categories-to-childrenpages/ […]
-
website bovenaan in Google
maj 14th, 2024 on 14:26… [Trackback]
[…] Here you can find 57094 additional Info on that Topic: from-rizo.se/how-to-prevent-episerver-to-inherit-categories-to-childrenpages/ […]
-
เครื่องกำจัดยุงแมลง
juni 9th, 2024 on 23:31… [Trackback]
[…] Here you will find 13734 more Info on that Topic: from-rizo.se/how-to-prevent-episerver-to-inherit-categories-to-childrenpages/ […]
-
lottovip
juni 22nd, 2024 on 00:55… [Trackback]
[…] Find More Information here on that Topic: from-rizo.se/how-to-prevent-episerver-to-inherit-categories-to-childrenpages/ […]
-
เพิ่มผู้ติดตาม
juli 1st, 2024 on 00:31… [Trackback]
[…] Information to that Topic: from-rizo.se/how-to-prevent-episerver-to-inherit-categories-to-childrenpages/ […]
-
ยาเพิ่มขนาดชาย
juli 5th, 2024 on 00:08… [Trackback]
[…] Info to that Topic: from-rizo.se/how-to-prevent-episerver-to-inherit-categories-to-childrenpages/ […]
-
safe eft cheat
augusti 24th, 2024 on 01:58… [Trackback]
[…] Read More to that Topic: from-rizo.se/how-to-prevent-episerver-to-inherit-categories-to-childrenpages/ […]
-
ราคาบอลสด แตกต่างจากราคาบอลทั่วไปอย่างไร?
augusti 31st, 2024 on 23:38… [Trackback]
[…] There you will find 6734 additional Information to that Topic: from-rizo.se/how-to-prevent-episerver-to-inherit-categories-to-childrenpages/ […]
-
สรุปรายละเอียดทั้งหมดเกี่ยวกับ sportsbetting
september 3rd, 2024 on 23:50… [Trackback]
[…] There you can find 17169 more Info to that Topic: from-rizo.se/how-to-prevent-episerver-to-inherit-categories-to-childrenpages/ […]
-
Buy Hornady Critical Defense Ammunition 12 Gauge 2-3/4" 00 Buckshot Box of 10 Online
september 10th, 2024 on 03:04… [Trackback]
[…] Read More on that Topic: from-rizo.se/how-to-prevent-episerver-to-inherit-categories-to-childrenpages/ […]
-
office for rent phuket
september 17th, 2024 on 01:51… [Trackback]
[…] There you can find 62379 additional Info on that Topic: from-rizo.se/how-to-prevent-episerver-to-inherit-categories-to-childrenpages/ […]
-
가입머니 지급
september 23rd, 2024 on 08:25… [Trackback]
[…] Info to that Topic: from-rizo.se/how-to-prevent-episerver-to-inherit-categories-to-childrenpages/ […]
-
Sylfirm
oktober 10th, 2024 on 06:24… [Trackback]
[…] Here you will find 52744 additional Info to that Topic: from-rizo.se/how-to-prevent-episerver-to-inherit-categories-to-childrenpages/ […]
-
Majestic bank link
oktober 28th, 2024 on 21:50… [Trackback]
[…] Read More here to that Topic: from-rizo.se/how-to-prevent-episerver-to-inherit-categories-to-childrenpages/ […]
april 26th, 2011 on 09:25
Unfortunately, this does not stop the control on the ”Categories” tab from being pre-selected.
However, the following, provided by the folks at EPiServer support, does the trick:
protected void Application_Start(Object sender, EventArgs e)
{
EPiServer.UI.Edit.EditPanel.LoadedPage += new EPiServer.UI.Edit.LoadedPageEventHandler(EditPanel_LoadedPage);
}
private void EditPanel_LoadedPage(EPiServer.UI.Edit.EditPanel sender, EPiServer.UI.Edit.LoadedPageEventArgs e)
{
if (e.Page.PageName == string.Empty) e.Page.Property[”PageCategory”].Clear();
}
maj 5th, 2011 on 10:19
Thanx for the feedback!
september 9th, 2011 on 19:21
It’s laborious to find educated folks on this matter, but you sound like you already know what you’re talking about! Thanks