Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

All other Modules /

Discuss all other Modules here.

Moderators: martimiz, Sean, Ed, biapar, Willr, Ingo, swaiba

Lumberjack: restrict child PageTypes


Go to End


3 Posts   1237 Views

Avatar
Sygmoral

Community Member, 46 Posts

21 April 2016 at 3:49pm

The Blog module now uses Lumberjack. I extended Blog and BlogHolder to create a News section, but I also still have an actual blog, so I'm using both classes.

On the News page, I have a nice green "Add News Item" button, but on the Blog page, I have a dropdown for BlogPost and NewsItem, and then a "Create new" button. I understand why this happens; it's showing all possible children types; but I only want 'basic' BlogPosts there, not its extensions.

Is there a way to (easily) force this? At least, the following does not help (does not seem to be picked up, whether I make it empty or ['BlogPost']):

<?php
class BlogExtension extends DataExtension {
    private static $allowed_children = [];
}

Avatar
Sygmoral

Community Member, 46 Posts

23 April 2016 at 4:43pm

One way to solve it is to create another new class that extends Blog and set its own allowed_children (MyBlog or something); that is the only solution I have found so far. I feel like it would make sense if this was possible with an Extension though, so I created an issue on github.

Avatar
Sygmoral

Community Member, 46 Posts

26 April 2016 at 4:19am

I eventually got a real solution thanks to the comments on the Github issue:
* use Config::inst()->remove and ->update in php
* write "*BlogPost" (including the asterisk) to indicate that only BlogPost and not classes extending it should be allowed

This is my effective result:

Config::inst()->remove('Blog', 'allowed_children');
Config::inst()->update('Blog', 'allowed_children', ['cwsFolderGalleryPage', '*BlogPost']);