From 8265f7859f53f6ef6e711cdeadbdd6e51fe618de Mon Sep 17 00:00:00 2001 From: Pascal Thormeier Date: Wed, 17 Apr 2019 09:26:25 +0200 Subject: [PATCH] Add anootation example to README and add default bootstrap template --- README.md | 29 ++++++++++++++++++- Resources/views/breadcrumbs.html.twig | 16 +++++----- .../views/breadcrumbs_bootstrap.html.twig | 17 +++++++++++ 3 files changed, 53 insertions(+), 9 deletions(-) create mode 100644 Resources/views/breadcrumbs_bootstrap.html.twig diff --git a/README.md b/README.md index c167b82..91c9958 100644 --- a/README.md +++ b/README.md @@ -83,6 +83,25 @@ If the current route is `acme_demo_catalogue`, the breadcrumbs would for instanc Home > Our Catalogue +Since the configuration of the breadcrumbs happens on routing config, it's generally agnostic from _how_ the routing +configuration happens. This means that configuring breadcrumbs for instance via annotations is perfectly possible: + + /** + * ... + * @Route( + * "/contact", + * name="course", + * options={ + * "breadcrumb" = { + * "label" = "Contact", + * "parent_route" = "acme_demo_home" + * } + * }) + * ... + */ + +The configuration can also be done in XML and PHP. + ### Dynamic routes If you happen to have dynamic routes or dynamic translations that you need in your breadcrumbs, they @@ -174,6 +193,14 @@ Call the twig extension as following: {# ... #} +### Using the bootstrap template + +The bundle also provides a default implementation for [Bootstrap](https://getbootstrap.com/docs/4.3/components/breadcrumb/). It can be used as follows: + + # config.yml + thormeier_breadcrumb: + template: @ThormeierBreadcrumb/breadcrumbs_bootstrap.html.twig + ### Replacing the default template If you want to use a custom template, add the following to your config.yml @@ -204,7 +231,7 @@ Your custom template might look something like this: **The replacing of `%%` with single `%` happens inside the template. See *"Dynamic routes"* as why this is needed.** -Have a look at `Resources/views/breadcrumbs.html.twig` to see the default implementation +Have a look at `Resources/views/breadcrumbs.html.twig` and `Resources/views/breadcrumbs_bootstrap.html.twig` to see the default implementations. ### Customize implementations diff --git a/Resources/views/breadcrumbs.html.twig b/Resources/views/breadcrumbs.html.twig index dbe3a2a..aeb9580 100644 --- a/Resources/views/breadcrumbs.html.twig +++ b/Resources/views/breadcrumbs.html.twig @@ -1,17 +1,17 @@ -{% if breadcrumbs|length %} +{%- if breadcrumbs|length %} -{% endif %} +{% endif -%} diff --git a/Resources/views/breadcrumbs_bootstrap.html.twig b/Resources/views/breadcrumbs_bootstrap.html.twig new file mode 100644 index 0000000..0d9b6c8 --- /dev/null +++ b/Resources/views/breadcrumbs_bootstrap.html.twig @@ -0,0 +1,17 @@ +{%- if breadcrumbs|length -%} + +{% endif -%}