Open dremdem opened 8 years ago
Hello !
Here is my couple files of my test project:
from flask import Flask from flask_menu import Menu, MenuEntryMixin from account import account from config import DefaultConfig from flask_breadcrumbs import Breadcrumbs app = Flask(__name__) app.config.from_object(DefaultConfig) Menu(app) app.register_blueprint(account) Breadcrumbs(app=app, init_menu=False) app.run(host='0.0.0.0',debug=True)
__init__.py
from flask import Blueprint, render_template_string, request from flask_menu import register_menu from flask_breadcrumbs import register_breadcrumb, default_breadcrumb_root, Breadcrumbs account = Blueprint('account', __name__ ) @account.route('/') #@register_menu(account, '.', 'Home') @register_breadcrumb(account, '.', 'Home') def index(): return render_template_string( """ {%- for breadcrumb in breadcrumbs -%} <a href="{{ breadcrumb.url }}">{{ breadcrumb.text }}</a> {{ '/' if not loop.last }} {%- endfor -%} """) @account.route('/first') #@register_menu(account, '.first', 'first') @register_breadcrumb(account, '.first', 'first') def first(): return render_template_string( """ {%- for breadcrumb in breadcrumbs -%} <a href="{{ breadcrumb.url }}">{{ breadcrumb.text }}</a> {{ '/' if not loop.last }} {%- endfor -%} """) @account.route('/first/f1') #@register_menu(account, '.first.f1', 'f1') @register_breadcrumb(account, '.first.f1', 'f1') def f1(): return render_template_string( """ {%- for breadcrumb in breadcrumbs -%} <a href="{{ breadcrumb.url }}">{{ breadcrumb.text }}</a> {{ '/' if not loop.last }} {%- endfor -%} """)
I tested it in different cases, but I can't make work it properly :(
In this case output like:
Menu item not initialised /Home /first
Please could you provide checked test example of code.
Best regards, Vladimir.
@dremdem please set account blueprint as a root by adding default_breadcrumb_root(account, '.') after account = Blueprint('account', __name__ ). `
account
default_breadcrumb_root(account, '.')
account = Blueprint('account', __name__ )
Hello !
Here is my couple files of my test project:
__init__.py
I tested it in different cases, but I can't make work it properly :(
In this case output like:
Menu item not initialised /Home /first
Please could you provide checked test example of code.
Best regards, Vladimir.