silverstripe-blog icon indicating copy to clipboard operation
silverstripe-blog copied to clipboard

$this->Tags()->relation('BlogPosts') doesn't work

Open wernerkrauss opened this issue 5 years ago • 2 comments

Currently I want to build a page exension that has a manymany relation to BlogTag so I can display related blog posts on other pages.

Unfortunately $this->Tags()->relation('BlogPosts') does not work, cause DataList::relation() tries to put some IDs when calling BlogTag::BlogPosts(), which is ignored by the BlogObject trait.

Fix in BlogObject:

    /**
     * @return DataList
     */
    public function BlogPosts($id = null)
    {
        $blogPosts = parent::BlogPosts($id);

        $this->extend('updateGetBlogPosts', $blogPosts);

        return $blogPosts;
    }

PRs:

  • [ ] https://github.com/silverstripe/silverstripe-blog/pull/621

wernerkrauss avatar Aug 10 '20 14:08 wernerkrauss

Hi! Thank you for reporting this. Would you like to make a Pull Request?

dnsl48 avatar Aug 18 '20 19:08 dnsl48

@dnsl48 I acceidently made a pull request against my own fork. Now fixed.

wernerkrauss avatar Aug 25 '20 14:08 wernerkrauss

The PR linked in the description was merged in 2020 - I assume that fixed the bug.

GuySartorelli avatar May 10 '24 03:05 GuySartorelli