XF 2.1 Extend navTree array from custom options?

Nulumia

Well-known member
I'm trying to add a few values (string/boolean) to the navTree array, following the typical title, href, attributes:

$navTree:
Code:
"home" => array [
    "title" => "Phrase"
    "href" => ""
    "attributes" => []
]
"forums" => array [
    "title" => "Phrase"
    "href" => ""
    "attributes" => []
    "myOption1" => "A custom string"
    "myOption2" => "Another string"
    "myOption3" => false
]

I've successfully added custom option fields to the Admin -> Public Navigation -> edit form, setup listeners and class extensions, and have the custom fields saving to the database under new columns added to xf_navigation (i.e. "navigation_myoption_1", "navigation_myoption_2" etc).

Where I'm stuck is adding these values to the array - I'm guessing this has to be done by adding a listener to the navigation_setup event? Or does this need to get messy with compiling the navigation?

Still new & learning with these concepts so any help is much appreciated!
 
  • Like
Reactions: eL_
Back
Top Bottom