-
Notifications
You must be signed in to change notification settings - Fork 0
JSON: templates
This file contains an array of template objects.
The 'struct' part of the template object is either a string (for the bits surrounding the menu) or a keyed-array of similar strings within one of the lvl objects.
This string simply tells Flexwalker when to open and to close tags, using the id of a tag within tags.json. There is one reserved word, 'walker', which inserts the wp_nav_menu return when used in the top struct. Otherwise, the string is a nesting key, with '/' used to close the last opened tag. In pseudo code, using the id as the tag, this struct:
nav toggle toggleicon / / walker /
Turns into this code
<nav>
<toggle>
<toggleicon></toggleicon>
</toggle>
<!-- returned menu from Flexwalker_Walker -->
</nav>
Note that within the lvl objects, there are opening and close structs for 'lvl' and 'el'. See below for an explanation of how they work.
A template object looks like this:
{
"id": "yourid",
"depth": 1,
"struct": "nav toggle toggleicon / / walker /",
"lvl": []
}-
idis what you use to get this template when callingflexwalker() -
depthis the menu depth and will override other walker depth arguments -
structdescribes the structure around the nav menu and its position within it -
lvlis an array containing 'lvl objects', described below
struct at this level allows you to put all menu-specific HTML here, which gives you more flexibility when coding your actual templates. If you need to go back to conventional menus instead of a deeply layered Bootstrap menu, for example, you can simply change which template you're using without having to modify the code in your theme header.