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

Support for Rainlab Forum? #75

Open
RCheesley opened this issue Mar 8, 2019 · 3 comments
Open

Support for Rainlab Forum? #75

RCheesley opened this issue Mar 8, 2019 · 3 comments

Comments

@RCheesley
Copy link

Hello,

I wondered if there was any possibility of supporting the RainLab Forum: https://octobercms.com/plugin/rainlab-forum to enable indexing of forum categories and posts?

@tobias-kuendig
Copy link
Member

You can actually add this pretty easy yourself by creating a custom plugin, then add this to the boot method (see https://github.com/OFFLINE-GmbH/oc-site-search-plugin#add-support-for-custom-plugin-contents):

public function boot()
{
    \Event::listen('offline.sitesearch.query', function ($query) {

        $items = \RainLab\Forum\Models\Post::where('subject', 'like', "%${query}%")
                                        ->orWhere('content', 'like', "%${query}%")
                                        ->get();

        $results = $items->map(function ($item) use ($query) {

            $relevance = mb_stripos($item->subject, $query) !== false ? 2 : 1;
            
		     return [
                'title'     => $item->subject,
                'text'      => $item->content,
                'url'       => '/post-url/' . $item->id,
                'relevance' => $relevance,
            ];
        });

        return [
            'provider' => 'Post', 
            'results'  => $results,
        ];
    });
}

Makre sure to fix the url property. I've never used the forum plugin so I don't know how it generates URLs.

Do the same again for channels or whatever data you need in the search results.

Will this work for you?

@RCheesley
Copy link
Author

Thanks, I have no idea as I'm not a developer, rather a user/administrator.

I'll see whether this helps the folk who would need to implement.

I was asking more from the perspective of a user, who saw a list of supported plugins including other RainLab ones, and wondering if their forums were likely to be added at some point as a supported plugin.

Thanks for the speedy reply!

@tobias-kuendig
Copy link
Member

I'll leave this issue open in case anyone has some spare time to implement it. It's not that complicated and would be a great addition to the plugin.

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

2 participants