2017-12-19 6 views
0

기본적으로 "게시 된"옵션을 "true"대신 "false"로 설정하고 싶습니다.apostropheCMS의 기본 페이지 무시 옵션

나는 아포스트로피 - 주문 페이지에서이 있었다하려고 :

을하지만 그것은 작동하지 않습니다! 손을 댈 수 있습니까?

감사

편집

: 어쩌면 내 기본 옵션은 다른 곳에서 오버라이드되는 완전한하는 index.js?

var _ = require('lodash'); 

module.exports = { 

    extend: 'apostrophe-doc-type-manager', 

    beforeConstruct: function(self, options) { 

options.name = options.name || self.__meta.name.replace(/\-pages$/, '-page'); 

if (options.permissionsFields === undefined) { 
    // By default, pages have nuanced permissions 
    options.permissionsFields = true; 
} 

options.addFields = [ 
    { 
    type: 'boolean', 
    name: 'published', 
    label: 'Published', 
    def:false 
    }, 
    { 
     type: 'slug', 
     name: 'slug', 
     label: 'Slug', 
     required: true, 
     // with this flag, a leading/is enforced, and slashes 
     // elsewhere are allowed etc. 
     page: true 
    }, 
    { 
     type: 'select', 
     name: 'type', 
     label: 'Type', 
     required: true, 
     choices: _.map(options.apos.pages.typeChoices, function(type) { 
     return { 
      value: type.name, 
      label: type.label 
     }; 
     }) 
    }, 
    { 
     type: 'boolean', 
     name: 'orphan', 
     label: 'Hide in Navigation' 
    } 
].concat(options.addFields || []); 

options.arrangeFields = [ 
    { 
    name: 'basics', 
    label: 'Basics', 
    fields: [ 'meta-description', 'title', 'slug', 'type','alaune', 'color', 'published', 'tags', 'orphan' ] 
    } 
].concat(options.arrangeFields || []); 

}, 

construct: function(self, options) { 
require('./lib/dispatch.js')(self, options); 
require('./lib/api.js')(self, options); 
} 
}; 

하하 나는이 사이트를 아주 좋아하지만, 더 많은 의견을 남기지 않고 코드를 게시 할 수는 없습니다. 글쎄, 내 문제는 설명하기가 매우 쉽다.

그래서 .. 아포스트로피 -CMS 팀에게 감사를 표합니다 ^^ 환자 지원에 대해 Tom!

+0

정상 작동합니다. 'beforeConstruct'에 넣었 니? 보다 완전한 코드를 게시하십시오. 감사! –

+0

Hello Tom, 답장을 보내실 분 다른 파일에서이 기본 옵션을 무시할 수 있습니까? – JGrimbert

답변

0

새로운 페이지의 게시 상태는 상위 페이지에서 상속됩니다. 이것은 apostrophe-pagesnewChild 메소드에서 구현됩니다.

당신이 당신 최상위 페이지를 생성 할 수 있습니다, 그래서 이것은, 솔직히 꽤 유용한 규칙이다는 게시 취소 한 다음 두 번째 수준 페이지 등의 규칙을 활용하는 수동으로 설정

또는 지금 홈페이지를 게시 취소하고 심지어 최상위 수준 페이지가 게시되지 않은 상태로 태어납니다 (출시 후 분명히 더 이상 원하지 않을 것입니다).

// in lib/modules/apostrophe-pages/index.js of your own project. 
// DO NOT modify it in node_modules, that is NEVER NECESSARY 

module.exports = { 
    construct: function(self, options) { 
    var superNewChild = self.newChild; 
    self.newChild = function(parentPage) { 
     var child = superNewChild(parentPage); 
     child.published = false; 
     return child; 
    }; 
    } 
}; 

우리는을 구현하는 풀 요청을 고려할 것입니다 :

하지만 실제로는 사용자의 요구 작동 이러한 시나리오 중 어느 것도, 당신은 당신이 원하는 것을 할 수있는 "슈퍼 패턴"을 통해 newChild 방법을 확장 할 수있는 경우

apostrophe-pages 모듈의 경우 unpublishNewChildPages과 같은 플래그. 그런 다음 위의 코드는 원래 구현 newChild의 일부가 될 수 있습니다.

FYI 공유 한 코드는 전체 모듈의 과도하게 완전한 복사본 인 것 같습니다. 프로젝트 레벨에 전체 모듈을 복사 할 필요가없는 한 가지만 재정의하려는 경우 (그렇다고해서는 안됩니다. 우리가 나중에 변경 한 사항에 대해 책임을지게 만듭니다.) 프로젝트 레벨의 핵심 아포스트로피 모듈은 자동으로 원본 버전을 하위 클래스로 분류하므로 원본 코드에 대한 걱정없이 개별적인 것을 무시할 수 있습니다. 여전히 실행됩니다.