django-sitetree icon indicating copy to clipboard operation
django-sitetree copied to clipboard

"hook" into tree with app

Open nerdoc opened this issue 5 years ago • 1 comments

It's more a question than a bug - maybe I didn't get it (or the docs aren't clear about that?), but:

How can I use different apps to "hook" into the main tree?

Use the case: I create an app with a sitetrees.py, using the following content:

from sitetree.utils import tree, item

sitetrees = (
    tree("maintree", items=[
        item("File", "#"), children=[
            item('New', 'base:newfile')
        ],
        item("Extras", "#", children=[
            item('Test', 'another_namespace:test_function')
        ]),
    ]),
)

Now I want to create a "plugin" app for that Django application, that provides an File/Open menu, and create a "open" app ./manage.py startapp open - with another sitetrees.py:

from sitetree.utils import tree, item

sitetrees = (
    tree("maintree", items=[
        item("File", "#"), children=[
            item('Open', 'base:openFile')
        ]
    ]),
)

It's obvious that this does not work, as it will overwrite the first maintree. How do I achieve that there are both, New and Open, under the File menu then?

Or is this not possible? Thanks.

nerdoc avatar Oct 11 '18 14:10 nerdoc

In the docs that's called attaching in dynamic trees, but not hooking. See in https://django-sitetree.readthedocs.io/en/latest/apps.html#dynamic-sitetree-structuring

compose_dynamic_tree('books', target_tree_alias='main', parent_tree_item_alias='for_books'),

Here in parent_tree_item_alias is the alias of an item (node) to attach to.

Hope that helps.

idlesign avatar Oct 12 '18 02:10 idlesign

Considered closed.

idlesign avatar Dec 22 '23 02:12 idlesign