Open raissanorth opened 6 years ago
Looks like this feature would need to be pushed over the line to resolve this: https://github.com/silverstripe/silverstripe-cms/pull/1171
We have a test configured in our CWP regression suite that has been failing on this broken behaviour since it was created. The above PR was eventually closed without merging, as it was targeted at CMS 3 and didn't make the cut before that was shifted into maintenance mode.
Would be good to address this at some point, but likely still requires a core change to facilitate it.
Would be good to address this at some point, but likely still requires a core change to facilitate it.
It can be done with canView()
- we usually resolve this with an extension:
<?php
namespace App\Extensions\Blog;
use SilverStripe\Blog\Model\Blog;
use SilverStripe\Core\Extension;
class BlogPostExtension extends Extension
{
/**
* @param mixed $member
* @param array $context
* @return bool|null
*/
public function canCreate($member = null, $context = []): ?bool
{
$parent = $context['Parent'] ?? null;
if (!$parent || !$parent instanceof Blog) {
return false;
}
return null;
}
}
This is still an issue in our regression test.
It is a bit odd and confusing that one can add a blog post under pages that are not of type blog. One even gets to see the preview within the CMS and it is therefore not immediately clear that the blog post is not actually visible on the live page.