Limiting Page Type on the Page Selector control

John Fu asked on December 11, 2014 05:39

Is there a way to restrict the page type on the page selector control so that when the editor selects a document, they are only able to select it from a particular page type?

Recent Answers


Adam Jackman-Moore answered on December 11, 2014 08:11

Not sure what you mean here.

However you can set restrictions on what pagetype a type of page type can add.

eg You can set it up so only "Pages" can be added to a "Folder" pagetype.

Go to PageTypes, then select the pagetype you want to allow/restrict and then choose the "Allowed Types" side tab. It will allow you to set the parent and child types for that page type.

0 votesVote for this answer Mark as a Correct answer

John Fu answered on December 11, 2014 11:16

Hi Adam, I think you got the wrong idea.

I'm configuring a field in a page type. And I'm using the Page Selector as the field's control, so that the editor can select a page from the content tree. But I want to restrict the pages they can choose from by page type.

0 votesVote for this answer Mark as a Correct answer

Vilém Jeniš answered on December 12, 2014 16:48

Hi!

There is no out of the box way to do that. However you can leverage the UniSelector with proper configuration and especially the where-condition. The drawback is that the use won't see the content tree.

Another way of doing what you need would be leveraging the validation macros. You could have the user select any document at all and have it validated by a validation rule of your choice. A bit clumsy for a First-Time user but they could "get used to it". Not the best UX I know... Or you can always do some customizations. No limits there.

Regards,

Vilém

0 votesVote for this answer Mark as a Correct answer

John Fu answered on December 15, 2014 04:56

Hi Vilém,

How do you utilize the validation macros? The types of validation rules I'm allowed are:

  • Compare to another field
  • Date from
  • Date to
  • Email
  • General Condition
  • Max Length
  • Max Value
  • Min Length
  • Min Value
  • Phone number (US)
  • Regex
  • US Zip Code
0 votesVote for this answer Mark as a Correct answer

John Fu answered on December 15, 2014 05:38

OK. I've worked out how to add Macro rules to that list. But what condition do I put in there?

I've tried... new TreeProvider().SelectSingleNode(CMS.DocumentEngine.TreePathUtils.GetNodeIdByNodeGUID(Guid.Parse(Value), CMS.SiteProvider.SiteContext.CurrentSiteName)).ClassName == "site.Promo"

But it doesn't work.

0 votesVote for this answer Mark as a Correct answer

Vilém Jeniš answered on December 15, 2014 10:53

You can use the 'general condition' and then either make a custom macro method to specifically validate your field, or you could write a rather complicated macro expression to ensure correct validation. I think, that writing the macro in C# and then being able to debug it in VS if easier and probably more efficient. But bot is possible.

If your macro expression doesn't work, you and you don't know why you can enable macro debug in settings and then refer to macro debug in the Debug app. It does not debug the C# code of the macro, but shows the evaluation steps with the results.

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.