Wagtail MultiSite - Cross posting content

喜夏-厌秋 提交于 2019-12-06 05:52:14

An idea would be to use a mix of using Wagtail Snippets and the RoutablePageMixin on your Events Index Pages.

1. Make an Events Snippet

Make the shared content of your Events page into a Wagtail Snippet. You will loose the ability to access versions of changes but gain the ability to share across sites.

http://docs.wagtail.io/en/v1.13/topics/snippets.html

2. Update your Events Index page model to use the RoutablePageMixin

http://docs.wagtail.io/en/v1.13/reference/contrib/routablepage.html

You can then hook into the URL calls for any of the Events Index pages if they have something like mydomain.com/events/123-event-name-as-slug. This can load a custom template (which can be shared or not, depending on the site), with the events index and the event snippet sent via the context.

These URLs will be their own unique URL but not actually have a page behind them. Remember to consider your SEO implications, ensure that the admin editors can manage things like meta description on the snippet (or work through how that will propagate automatically).

You can also hook into the Wagtail button (called Wagtail Userbar) so that when editors click the front end Wagtail button and click 'edit Event' it can take them directly to the Snippet editing page in admin.

http://docs.wagtail.io/en/v1.13/reference/hooks.html#construct-wagtail-userbar

3. Update Events Index Listing

If there are some events you do not want on both sites, you could add checkboxes (both ticked by default) for the two sites you operate. This means the Events Index page will only show the events relevant to that site.

You can do this by overriding the serve method on the page model.

Note: In this example you are not explicitly linking each and every event to each site's event index page. You are simply loading a query of relevant events and passing it to the events index template.

4. More Complex Integration

If you really want an individual page for each 'Event' under each site, you could create a custom signal on Snippet create/edit/delete.

Intro to Wagtail Signals: http://docs.wagtail.io/en/v1.13/reference/signals.html

You would want to ensure that the fields are non-editable on the Page edit, but would be editable under snippets. Then you just keep things in sync with your signals, bit messy but gives you an actual 'Page' in the Admin.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!