diff --git a/docs/advanced_topics/i18n/duplicate_tree.rst b/docs/advanced_topics/i18n/duplicate_tree.rst index 010f18e91f..2ceb89dfbe 100644 --- a/docs/advanced_topics/i18n/duplicate_tree.rst +++ b/docs/advanced_topics/i18n/duplicate_tree.rst @@ -58,12 +58,21 @@ Here's an example of how this could be implemented (with English as the main lan .. code-block:: python + from wagtail.wagtailcore.models import Page + from wagtail.wagtailadmin.edit_handlers import MultiFieldPanel, PageChooserPanel + + class TranslatablePageMixin(models.Model): # One link for each alternative language # These should only be used on the main language page (english) french_link = models.ForeignKey(Page, null=True, on_delete=models.SET_NULL, blank=True, related_name='+') spanish_link = models.ForeignKey(Page, null=True, on_delete=models.SET_NULL, blank=True, related_name='+') + panels = [ + PageChooserPanel('french_link'), + PageChooserPanel('spanish_link'), + ] + def get_language(self): """ This returns the language code for this page. @@ -121,10 +130,18 @@ Here's an example of how this could be implemented (with English as the main lan class AboutPage(Page, TranslatablePageMixin): ... + content_panels = [ + ... + MultiFieldPanel(TranslatablePageMixin.panels, 'Language links') + ] class ContactPage(Page, TranslatablePageMixin): ... + content_panels = [ + ... + MultiFieldPanel(TranslatablePageMixin.panels, 'Language links') + ] You can make use of these methods in your template by doing: