Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Blog posts can be created under non-blog pages #521

Open
raissanorth opened this issue Mar 23, 2018 · 4 comments
Open

Blog posts can be created under non-blog pages #521

raissanorth opened this issue Mar 23, 2018 · 4 comments

Comments

@raissanorth
Copy link
Contributor

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.

@dhensby
Copy link
Contributor

dhensby commented Mar 23, 2018

Looks like this feature would need to be pushed over the line to resolve this: silverstripe/silverstripe-cms#1171

@Cheddam
Copy link
Member

Cheddam commented Nov 19, 2019

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.

@kinglozzer
Copy link
Member

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;
    }
}

@maxime-rainville
Copy link

maxime-rainville commented Jul 3, 2020

This is still an issue in our regression test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

8 participants