Available Page Types in EPiServer

image_thumb[10]It is a best practice to limit the number of Pages Types an editor can choose from when the editor creates a new page.

As you probably know this is configured in Admin Mode on each Page Type. What you probably don’t think about is that these settings can make it impossible to import and export pages.

“Available Page Types”-rules can break import

If your rules change over time or if you use Stop Publish and Archive Page so your pages moves around you can get in trouble with these rules.

In the current version (5.1.422.122 SP1) the import will stop with an error and it can be quite hard to figure out what is wrong.

I created a SQL-statement to help you figure out what is wrong. It will give you a list of all pages breaking the “Available Page Types”-rules. It lists the Parent and Child’s Page Id, Page Name and also Page Type.

image

This (messy) SQL statement for copy paste:

SELECT fkParentID AS ParentPageId, pkID AS ChildPageId, (SELECT Name FROM tblPage AS p2 WHERE (pkID = p.fkParentID)) AS ParentPageName, Name AS ChildPageName, (SELECT fkPageTypeID FROM tblPage AS p2 WHERE (pkID = p.fkParentID)) AS ParentPageTypeId, fkPageTypeID AS ChildPageTypeId FROM tblPage AS p WHERE (NOT EXISTS (SELECT fkPageTypeParentID, fkPageTypeChildID, Access FROM tblPageTypeToPageType AS tt WHERE (fkPageTypeParentID = (SELECT fkPageTypeID FROM tblPage AS p2 WHERE (pkID = p.fkParentID))) AND (fkPageTypeChildID = p.fkPageTypeID))) AND EXISTS (SELECT fkPageTypeParentID, fkPageTypeChildID, Access FROM tblPageTypeToPageType AS tt WHERE (fkPageTypeParentID = (SELECT fkPageTypeID FROM tblPage AS p2 WHERE (pkID = p.fkParentID))))

Bookmark and Share

Tags: , , , , ,

  1. Diego Delfino’s avatar

    hej Fredrik,

    Finns det ett sätt att kunna bestämma vilken sidtyp som skall visas för en specifik sida beroende på den aktuella sidans förrällder via kod kanske?

    Ett exempel:

    Jag befinner mig under en del av ett sträd och jag skapar en lista, listsidtypen säger att jag bara kan skapa en specifik sidtyp under denna vilket är ok men under en annan del av trädet vill jag använda mig utav samma sidtyp för att skapa en lista och jag vill att denna sidtyp (som är samma som i andra delen av trädet) visar andra sidtyper jag kan skapa under den. Allt detta skall bero inte på den aktuella sidtypen jag skapar sidan under utan på dess förällder.

    Tack på förhand
    Diego Delfino

    Reply

  2. Fredrik Haglund’s avatar

    Hi Diego!

    I can not see any possibility too control available page types with code. If you use a Reflector and reveres engineer the NewPage class you can see that it retrives the list of page types from the database.

    Best suggestion is to have several Page Types with diffrent configuration but pointing to the same aspx-file.

    /Fredrik

    Reply

  3. Diego Delfino’s avatar

    Hi Fredrik,

    I have managed to come up to a partial solution and would much apreciate your guidence in the following steps.

    I have now created a property for the page i want to use as a container, this page gets the systems available parent types from a list in the web.config file. I would need some suggestion if you have to override the code that corresponds to tha determination of witch page types to make available for a page type and by this just comparing the parent type with the one the admin has defined in the page three.
    any suggestions?
    best reegards
    Diego Delfino

    Reply

  4. Fredrik Haglund’s avatar

    Sorry, can not see that it is possible to override that code the way you would like. It can be done if you start changing files from EPiServer with their User Interface but that is not recommended.

    Look at OnLoad() at NewPage class and PageTypeDB.ListForNewPage() and you will see that there are no easy way to hook or override this.

    The only workaround I can think of is to us an undocumented feature and insert allowed page types for a single page directly into tblPageToPageType. There is no API to do this so you have to change the database directly.

    Reply

  5. Diego Delfino’s avatar

    Hi fredrik,

    I have been thinking of your last suggestion and it looks like it may be the only answer, I do fear a little that the Database calls would increasy conciderably becasue of calls to check that state on every page type created. It is by far the best suggestion I have heard yet. I was also looking into the PageType class and hopping to change the outcome of every page from there but that seems to only make it worse and i don’t beleive in that straight.

    keep you posted on my progress
    Diego

    Reply