Skip to content
This repository was archived by the owner on Feb 17, 2025. It is now read-only.

Conversation

@pbking
Copy link
Contributor

@pbking pbking commented Apr 14, 2021

This is an experiment to see if a "classic menu data source" can be used in the Navigation Block.

This branch of Gutenberg (from my fork) is needed to test out that functionality.

When a navigation block has NO child items it will attempt this alternate rendering.

The change renders a menu using the classic method wp_nav_menu() and modifies as much as possible using the provided tools to make the result appear like the navigation block. The remainder is done with DOM/string manipulation.

image

Thoughts

Ideally the Navigation block is able to target this data source and use that as the source of menu options instead of IMPORTING that data and storing it on the block.

The block could be given a control in the block editor so that a classic "source" can be chosen to be rendered dynamically OR child 'nav' blocks could be added.

Even better would be the ability for the navigation block to allow for editing of this data and persist it (as data instead of as blocks).

EVEN IF the ability to target a menu location is ONLY available as a hand-coded attribute in a block-template this still provides value as a tool themes can use during the transitional time.

ALTERNATIVELY rather than adding this (handy dandy) functionality to the Navigation block another "Classic Navigation" block could be created where that is the only purpose (rendering classic navigation data) which could just be swapped out for a regular Navigation block at the appropriate time.

<!-- wp:navigation-link {"label":"Home","url":"#"} /-->
<div class="wp-block-column is-vertically-aligned-center">

<!-- wp:navigation {"orientation":"horizontal","itemsJustification":"right","source":"primary"} -->
Copy link
Contributor

@jffng jffng Apr 14, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I love this API of identifying a nav area to render via a block attribute.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+10000

@jffng
Copy link
Contributor

jffng commented Apr 15, 2021

I gave this another spin and it worked swimmingly when I had a navigation menu defined and set to display in the "Primary" nav area.

I tried to de-activate the menu to see what would happen, and got caught in a loop:

Screen Shot 2021-04-15 at 6 05 09 PM

Not sure what may be causing this.

@MaggieCabrera MaggieCabrera added this to the Quadrat v1 milestone Apr 20, 2021
@scruffian scruffian force-pushed the make/quadrat branch 2 times, most recently from 0b57627 to fd635dd Compare April 26, 2021 16:09
Base automatically changed from make/quadrat to trunk May 6, 2021 15:06
@pbking
Copy link
Contributor Author

pbking commented May 10, 2021

The PR has triggered a lot of conversation but the branch has a lot of extra baggage. Closing this, though some of the ideas may live on...

@pbking pbking closed this May 10, 2021
@pbking pbking deleted the try/classic-menu-data-source branch September 13, 2021 17:55
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants