문제

I'm currently in the progress of migrating a static, HTML site to Silverstripe. One of the challenges that I'm facing is a design completed with static HTML in mind.

The navigation area of the site is designed only to hold 4 top-level navigation items. The sub-nav can, in theory, have as many as is needed.

Is it possible for me to enforce a limit in the CMS on the maximum # of top-level pages that the users can create?

Thanks in advance.

도움이 되었습니까?

해결책

This really depends on the page types that you're creating. If you have a single page type and only 4 pages then just override the canCreate function (see below) within your Page class. If you have multiple pages but your root level pages are the same page type then use the same method but also add the can_be_root static var to the child page types (private static $can_be_root = false;).

e.g.

function canCreate() { 
    $count = DataList::create(“SiteTree”)->Count(); 
    return ($count > 4) ? false : true; 
};

Hopefully this is enough info for your particular situation.

See SilverStripe SiteTree documentation.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top