Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 222
Pezholio Avatar asked Oct 14 '25 02:10

Pezholio


2 Answers

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!

like image 64
timo.rieber Avatar answered Oct 16 '25 17:10

timo.rieber


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."

like image 30
Francisco Giraldo Avatar answered Oct 16 '25 16:10

Francisco Giraldo



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!