I have a tendency to over-engineer or oversimplify or even miss obvious solutions.
The problem with the solution I provide is that the front end, UX, TTW config is absolutely horrendous and needs to be shot, burned, buried, and removed from history books so younger generations won't be poisoned by dangerous ideas. Please help.
Here's the request:
I want navigation on my header such that:
- I can have sub-navigation under main navigation.
- navigation is NOT driven by content
(no queries for folders and 'exclude from nav' and navigation depth and all that slowness) - navigation is NOT driven by objects in the database - some navigation items may actually go off-domain and link to other sites.
- I want to configure it. (basically, I don't want to write HTML, so this must be TTW)
Solution: Drop Plone's navigation completely and design my own control panel config:
My schema - as simple as possible, is a single list (main naviation) of lists (sub navigations) of 'Header elements" (a structure containing a title and a url)
class IHeaderElement(Interface):
name = field.TextLine(
title="Link Name",
required=True
)
url = schema.ASCIILine(
title="Link URL",
description=u'A tales string expression (string:) producing the called URL. '
u'Example: ${navigationRootUrl}/page'
u'see header.pt for available variables.',
required=True,
)
class INavigationSettings(Interface):
main_navigation_items = field.List(
title="Navigation Items",
description="""The First element in each list is the 'Section' Navigation Column Header.
Additional elements are additional 'sub-sections' under that header """,
required=True,
value_type=field.List(
title="Navigation Column",
value_type=PersistentObject(IHeaderElement),
required=False,
),
)
There's a lot of other code required to get 'value_type = object' to work that I'm ignoring for the moment.
Then just throw this at plone.app.registry (z3c.form undereath, I think) and "Make Me A Form, Damnit!"
I'm on a K.I.S.S. kick now and really trying to avoid going down the rabbit hole.
class NavigationSettingsEditForm(RegistryEditForm):
"""
Define form logic
"""
schema = INavigationSettings
label = "Site Settings - Navigation"
class NavigationSettingsView(ControlPanelFormWrapper):
form = NavigationSettingsEditForm
<configlet
title="Navigation Settings"
action_id="myslte.settings.navigation"
appId="mysite.settings"
category="Products"
condition_expr=""
url_expr="string:${portal_url}/@@rfa-navigation-settings"
icon_expr=""
visible="True"
i18n:attributes="title">
<permission>Manage portal</permission>
</configlet>
Honestly, I spent too long on this problem with trying different approaches and throwing them away, and ran out of time to provide a solution I like, so here we are.
Now, if you want to configure your navigation, you end up with this horrible interface:
You can't really tell if you're adding a column or a row (a main nav or subnav)
You can't re-order things. Want to put a column between navigation columns 3 and 4? HA HA HA HA!
you can't tell what checkbox is next to what object...
So, in running out of time, this is what got delivered, and I'm really upset about it. Lists should have order and insert operations, but the widget used is just dumb about it.
Does anybody have a quick idea how to make this form look better? do I have to design my own custom form and custom javascript to maintain a list of lists of objects?
Does anyone know what username Annette Lewis hides behind? (send me a PM, I'll keep you anonymous, I promise.)