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

Some improvemens #161

Open
wants to merge 13 commits into
base: master
Choose a base branch
from
Open

Some improvemens #161

wants to merge 13 commits into from

Conversation

vit-ivanov
Copy link

Hi!

I've made some changes, that could be useful maybe.

as for sitetree_menu and sitetree_children templatetags.

Can be useful, when we have fixed depth menu with different styles for levels.

i18n_patterns improvements.

Possibly, fix for #123 .

I have a part on my site, which is translated into 5 languages,
using i18n_patterns for handling requests. All content, menu structure etc
are absolutely the same. That's why I don't want to use 'built-in' internationalization system — I don't want 5 identical menus, so I use django-modeltranslation.

I've made a menu, something like that:

  • Home /eu/
  • - About /eu/about/
  • - - Structure /eu/about/structure/

But when the real request.path was '/ru/eu/about/' current_item was None.
Other issue is that {% sitetree_url %} returned url without current language prefix.

I fixed both, and I think my proposal keeps backwards compatibility.

softroots

We already discussed it here #145 .
I call it 'softroots' now, like in django-cms menu (http://docs.django-cms.org/en/2.4.2/getting_started/navigation.html#soft-roots).
Softroot is an item acting like root when climbing up the tree.

The difference with django-cms way is that my proposal is to make softroots 'named'. So one item could by softroot for topmenu, other for leftmenu, and another for both.

For example:

  • Root
  • - A
  • - - A1
  • - - A2
  • - B
  • - - B1
  • - - - B1A
  • - - B2
  • - C

For example, we can make "B" a softroot for 'topmenu', and "B1" would be softroot for 'leftmenu'. Let current item be "B1A".
{% sitetree_menu from "ourtree" include "this-softroot" name "topmenu" %} will climb up to "B" and use "B" as parent.
{% sitetree_menu from "ourtree" include "this-softroot" name "leftmenu" %} will climb up to "B1" and use "B1" as parent.

I've added name arg for sitetree_menu and sitetree_children, it is rendered menu name.
I've added softroot_for field to TreeItem model, it is a comma separated list of menu names, for which this item acts like softroot.

hide_from

Since we have a concept of menu names, we can toggle item visibility according to menu name, not only for the whole menu.

I've added hide_from field to TreeItem model, it is a comma separated list of menu names, for which this item is hidden.

with_parents

  • Root
  • - A
  • - - A1
  • - - A2

When current item is "A", "A1" or "A2" I need my left menu to be [A, A1, A2] i.e. I want parent to be the first menu element.

I've added include_parent arg for sitetree_menu, when it's set, parents will be included to menu items.

Usage: {% sitetree_menu from "ourtree" include "this-softroot" name "topmenu" include_parent %}

Has this pull request a chance to be merged? Maybe some parts :)

@landscape-bot
Copy link

Code Health
Repository health decreased by 1% when pulling 4e86505 on vit-ivanov:master into f3ee011 on idlesign:master.

@idlesign
Copy link
Owner

Hi,

Yeah, that's quite a bunch of changes %) Sounds interesting.
Yet nowadays I have a limited time to dedicate to github, so it might take some time to digest.

Thank you!

@idlesign
Copy link
Owner

idlesign commented Jul 8, 2015

I'm almost positive about as and include_parent, the other three need further consideration. I feel especially uneasy about comma-separated fields.
I'd also like to ask you to make put those cnahes into different pull requests, so that we could see what test are failed, and what needs to be improved.

@landscape-bot
Copy link

Code Health
Repository health decreased by 1% when pulling e6f8e67 on vit-ivanov:master into f3ee011 on idlesign:master.

Vladimir Sinitsin and others added 2 commits October 12, 2015 18:44
Soft menu for root for django native migrations
Django native migration fix
@landscape-bot
Copy link

Code Health
Repository health increased by 0.68% when pulling a85faad on vit-ivanov:master into f3ee011 on idlesign:master.

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

Successfully merging this pull request may close these issues.

None yet

4 participants