Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

For Dex Content types behavior "Exclude From Navigation" could use additional setting #178

Open
rileydog opened this issue Mar 17, 2023 · 1 comment

Comments

@rileydog
Copy link

If the Exclude From Navigation" is selected, that means it will be an option in each instance of the content type created. However, the creator of the content must manually go in and select the "hide from navigation" option.

suggest another Behavior option: "Always Exclude from Navigation". This will add the check box "exclude from navigation" however, this would be checked by default.

This allows the person creating the new content type to set the dessired default behavior

@davisagli
Copy link
Member

We added a custom behavior for this in one project:

excl_from_nav.py:

"""A modified version of the plone.excludefromnavigation behavior

This one sets exclude_from_nav to True by default.
"""
from plone.autoform.interfaces import IFormFieldProvider
from plone.base import PloneMessageFactory as PMF
from plone.supermodel import model
from zope import schema
from zope.interface import provider


@provider(IFormFieldProvider)
class IExcludeFromNavigation(model.Schema):
    """Behavior interface to exclude items from navigation."""

    exclude_from_nav = schema.Bool(
        title=PMF("label_exclude_from_nav", default="Exclude from navigation"),
        description=PMF(
            "help_exclude_from_nav",
            default="If selected, this item will not appear in the navigation tree",
        ),
        default=True,
        required=False,
    )

configure.zcml:

<configure
    xmlns="http://namespaces.zope.org/zope"
    xmlns:plone="http://namespaces.plone.org/plone"
    >

  <plone:behavior
      name="myproject.excludefromnavigation"
      title="Exclude From navigation"
      description="Allow items to be excluded from navigation (default: True)"
      provides=".exclude_from_nav.IExcludeFromNavigation"
      />

</configure>

It's too bad we don't have a good way to have a single behavior but then let the admin configure the default value of the field. I worry that having two different behaviors providing the same field would be confusing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants