dsj0312 2014-02-13 20:28
浏览 12
已采纳

我可以对Silverstripe中的顶级页面数量施加限制吗?

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.

  • 写回答

1条回答 默认 最新

  • dongyuan1984 2014-02-13 21:28
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 unity第一人称射击小游戏,有demo,在原脚本的基础上进行修改以达到要求
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line