Embed a Commons Group forum to a Site page
Ann Del Principe from Kingsborough would like to display her group forum on a page of her group site. Is it possible to create a custom iframe shortcode for this? Or another solution?
#1 Updated by Raymond Hoh 26 days ago
Provided that the group is public, it's possible to use the RSS feed for a group. For example,
https://commons.gc.cuny.edu/groups/cuny-pie/feed/. However, this includes all group activity.
Then if you're using the Block Editor, you can use the RSS block to add the RSS URL to display the feed that way.
If we wanted to limit the group RSS feed to be more granular for forum posts, we will need to write some custom code so the feed URL could be customized. Shouldn't take too much code. If we're interested in this direction, let me know.
#2 Updated by Raymond Hoh 26 days ago
- Assignee set to Raymond Hoh
After the maintenance release tomorrow (September 28th), you'll be able to use the following RSS feeds to grab the group forum activity:
- Group activity RSS URL, powered by BuddyPress and filtered by forum activity:
- Group forum RSS URL, powered by bbPress:
cuny-pie to the group's slug. The group must be public as well. Combine this with the Block Editor's RSS block as mentioned above and Ann should be good to go.
If Ann isn't using the Block Editor, it looks like we have two RSS embedding plugins -- RSSImport and RSS Multi Importer -- that could work, however they're both a little old and will need some testing.
If that isn't enough, let us know.
(Code reference: https://github.com/cuny-academic-commons/cac/commit/2507b0faaf79c05f10658444e9aa596ae2772507, https://github.com/cuny-academic-commons/cac/commit/cc034672c199a87d9231e9e16796eeae66e0c0cf)
#5 Updated by Raymond Hoh 24 days ago
Unfortunately, the RSS solution I posted above would only work if the group is public due to privacy issues.
Boone, I just remembered that I have some prior art in our BP Event Organiser plugin to embed a group calendar using a minimal version of the page. For example,
We can accomplish something similar for our group forums. Then Ann can embed the forum using a shortcode like
[group-forum slug="cuny-pie"], which would call on the iframe.
I've actually put something together locally and it works quite well. Code isn't large; it's about 60 lines of code plus a custom template file (still need to write the shortcode).
Just so there isn't two entry points, if you're viewing the embedded forum, I've made it so it's basically read-only. The new topic post form is removed and clicking on a topic link will load the full version of the page and not in the iframe. If the group is private, we'll have to do some membership checks before rendering the iframe in the shortcode.
If you want me to move forward with this idea, I can put something up on cdev for testing.
#7 Updated by Raymond Hoh 22 days ago
I've got a first pass of this ready on cdev.
To test, use the following shortcode in a post or page:
[group-forum slug="xxx" height="800"]
xxx is the group slug. For example in the group URL,
digital-humanities-initiative" is the group slug.
height is optional and defaults to 600.
If the group is public, the forum is embedded.
If the group is not public:
- When logged out, you will see the following message: "
To view this group forum, please login and ensure you are a member of the group."
- When logged in, but not a member of the group, you will see the following message if the group is private: "
You do not have access to view this group forum. You can request membership to the group here." If the group is hidden, you will see the following message: "
You do not have access to view this group forum. Please contact the site administrator to request access to the group."
An example can be found on cdev here:
For those that cannot access cdev, I've attached a logged-out screenshot embedding two group forums on a page: One from a public group and one from a private group: https://redmine.gc.cuny.edu/attachments/19812/group-forum%20shortcode.jpg.
#9 Updated by Raymond Hoh 16 days ago
- Status changed from New to Staged for Production Release
- Target version changed from 1.19.0 to 1.18.20
I've committed the code here: https://github.com/cuny-academic-commons/cac/commit/d8ebd28bf5163f5f4b151823a61380258af6f38f.
After the next maintenance release on the 12th, Ann should be able to use the
[group-forum] shortcode and the group forum should display under the circumstances I explained here.
We should also document this on the Help site somewhere, but can wait until later to do this.
#10 Updated by scott voth 12 days ago
Thanks Ray. I have added documentation here - https://help.commons.gc.cuny.edu/embed-a-group-forum-on-a-site-page/