Try our conversational search powered by Generative AI!

Check if PageData has no template

Vote:
 

Hi,

Ok so I've taken the XML sitemap creation admin plugin work someone did and I'm trying to make it better.


So I'm trying to stop it creating a XML node for sites that are container pages, i.e. dont have a template associated with them when I use page type builder.

The thing is when I check the PageData.HasTemplate it's always populated with true ARRGHH! That's no use then is it!

So I've found that you can change the Link Type in the Shortcut section to no link only text, but I don't want to set than manually. I want to filter out pages automatically which I've set with no Filename in the PTB class attribute.


Anyone have any ideas or eitehr how to set this link type in the PTB class in the code or another work-around. See what I'm setting my container pages like this:

[PageType("B9F7EFB8-4DF2-11E1-988B-CBF74724019B",
    Name = "Container",
    Description = "A container page type, used like a folder",
    Filename = "")]

 

Cheers,

Kevin

#59426
Jun 08, 2012 9:32
Vote:
 

To create container page types with PTB you can do something like this:

public class SectionPage : TypedPageData
{
	public SectionPage()
	{
		HasTemplate = false;
	}
}

Then you can check the HasTemplate property inside your code and filter out pages that don't have templates. I've also created an extension method that does this, you can find it in the Extension library for EPiServer CMS.

Hope this helps

Frederik

#59430
Jun 08, 2012 11:10
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.