Pezholio
Pezholio

Reputation: 2674

Wagtail - extending PageChooserBlock to support external URLs

I'm building a site with Wagtail and using StreamField to build up content on a homepage. I've built a block that allows users to add featured links, which could be internal or external links. Currently the featured links have both a PageChooserBlock and a URLBlock, but I'd like to add a new custom block type that allows a user to specify either an internal page or a URL. I can't see anything in the docs that would help me. Any ideas where to start?

Upvotes: 4

Views: 1201

Answers (2)

Francisco Giraldo
Francisco Giraldo

Reputation: 91

you can use this library: https://pypi.org/project/wagtail-link-block/

From the docs:

"A link block to use as part of other StructBlocks which lets the user choose a link either to a Page, Document, or external URL, and whether or not they want the link to open in a new window."

Upvotes: 1

timo.rieber
timo.rieber

Reputation: 3867

This is nothing Wagtail supports yet, but there's a lot of interest in this feature, see issue https://github.com/wagtail/wagtail/issues/3141.

To solve this there is a pull request work in progress (see https://github.com/wagtail/wagtail/pull/1645) that aims to unify link choosers.

Maybe you are able to contribute, I'm sure this would be very welcome!

Upvotes: 4

Related Questions