{"id":18773115,"url":"https://github.com/webfactory/webfactorynavigationbundle","last_synced_at":"2025-09-07T02:03:57.252Z","repository":{"id":35373656,"uuid":"39636711","full_name":"webfactory/WebfactoryNavigationBundle","owner":"webfactory","description":"Allows to define the tree structure and to render website navigation menus","archived":false,"fork":false,"pushed_at":"2024-11-06T14:44:39.000Z","size":218,"stargazers_count":3,"open_issues_count":1,"forks_count":1,"subscribers_count":7,"default_branch":"master","last_synced_at":"2025-04-13T09:07:14.372Z","etag":null,"topics":["bundle","navigation","php","symfony"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/webfactory.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2015-07-24T13:54:55.000Z","updated_at":"2024-11-06T14:44:24.000Z","dependencies_parsed_at":"2024-01-08T19:27:05.302Z","dependency_job_id":"6837637a-8e8a-494e-8bc1-8953ae56138e","html_url":"https://github.com/webfactory/WebfactoryNavigationBundle","commit_stats":{"total_commits":216,"total_committers":12,"mean_commits":18.0,"dds":0.7175925925925926,"last_synced_commit":"3557703982b828baa29ff5d5a984f4ec793d37fd"},"previous_names":[],"tags_count":91,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webfactory%2FWebfactoryNavigationBundle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webfactory%2FWebfactoryNavigationBundle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webfactory%2FWebfactoryNavigationBundle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webfactory%2FWebfactoryNavigationBundle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/webfactory","download_url":"https://codeload.github.com/webfactory/WebfactoryNavigationBundle/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248688568,"owners_count":21145766,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bundle","navigation","php","symfony"],"created_at":"2024-11-07T19:32:50.305Z","updated_at":"2025-04-13T09:07:23.952Z","avatar_url":"https://github.com/webfactory.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"WebfactoryNavigationBundle\n==========================\n\nSymfony Bundle featuring:\n\n- A factory for creating the navigation tree, using BuildDirectors which you can add to, if needed\n- Twig functions for rendering navigation elements (tree, ancestry, breadcrumbs) and inspecting the navigation tree\n\n\nInstallation\n------------\n\n    composer require webfactory/navigation-bundle \n\n... and activate the bundle in your kernel, depending on your Symfony version.\n\n\nRendering navigation elements in Twig\n-------------------------------------\n\n### Simple Navigation List\n\n#### Syntax\n\n    {{ navigation_tree(root, maxLevels = 1, expandedLevel = 1, template = '@WebfactoryNavigation/Navigation/navigation.html.twig') }}\n\n#### Examples\n    \n    {{ navigation_tree(root = {\"webfactory_pages.page_id\": root_page_id}) }}\n    \n    {{ navigation_tree(\n      root = {\"webfactory_pages.page_id\": root_page_id, \"_locale\": app.request.locale},\n      template = 'AppBundle:Navigation:navigation.html.twig'\n    ) }}\n\n### Ancestry List\n\nAn ancestry list is the active path from the given start level to the currently active node. Useful if you want to render\ne.g. the third level navigation outside of the regular navigation.\n\n#### Syntax\n    {{ navigation_ancestry(startLevel, maxLevels = 1, expandedLevels = 1, template = '@WebfactoryNavigation/Navigation/navigation.html.twig') }}\n\n#### Examples\n\n    {{ navigation_ancestry(startLevel = 1) }}\n    \n    {{ navigation_ancestry(startLevel = 1, template = '@App/Navigation/secondaryNav.html.twig') }}\n\n### Breadcrumbs\n\n#### Syntax\n\n    {{ navigation_breadcrumbs(template = '@WebfactoryNavigation/Navigation/breadcrumbs.html.twig') }}\n\n#### Examples\n\n    {{ navigation_breadcrumbs() }}\n    {{ navigation_breadcrumbs(template = '@App/Navigation/breadcrumbs.html.twig') }}\n\n### Customisation\n\nFor each function mentioned above you can provide a Twig template in which you can extend the base template and\noverwrite each block. Please find the default blocks in `src/Resources/views/Navigation/navigationBlocks.html.twig`.\n\nExample:\n\n```twig\n{# layout.html.twig: #}\n\n...\n{{ navigation_tree(root = {\"webfactory_pages.page_id\": root_page_id}, template = 'AppBundle:Navigation:navigation.html.twig') }}\n...\n```\n\n```twig\n{# AppBundle:Navigation:navigation.html.twig: #}\n\n{% extends \"@WebfactoryNavigation/Navigation/navigation.html.twig\" %}\n\n{% block navigation_list %}\n    \u003cnav class=\"project-specific-classes\"\u003e\n        {{ parent() }}\n    \u003c/nav\u003e\n{% endblock %}\n```    \n\n\nModifying the NavigationTree\n----------------------------\n\nImplement a `Webfactory\\Bundle\\NavigationBundle\\Build\\BuildDirector`. Example:\n\n```php\n\u003c?php\n\nnamespace AppBundle\\Navigation;\n\nuse JMS\\ObjectRouting\\ObjectRouter;\nuse Symfony\\Component\\Config\\Resource\\FileResource;\nuse Webfactory\\Bundle\\NavigationBundle\\Build\\BuildContext;\nuse Webfactory\\Bundle\\NavigationBundle\\Build\\BuildDirector;\nuse Webfactory\\Bundle\\NavigationBundle\\Build\\BuildDispatcher;\nuse Webfactory\\Bundle\\NavigationBundle\\Tree\\Tree;\nuse Webfactory\\Bundle\\WfdMetaBundle\\Config\\DoctrineEntityClassResource;\n\nfinal class KeyActionBuildDirector implements BuildDirector\n{\n    /** @var YourEntityRepository */\n    private $repository;\n\n    /** @var ObjectRouter */\n    private $objectRouter;\n\n    public function __construct(YourEntityRepository $repository, ObjectRouter $objectRouter)\n    {\n        $this-\u003erepository = $repository;\n        $this-\u003eobjectRouter = $objectRouter;\n    }\n\n    public function build(BuildContext $context, Tree $tree, BuildDispatcher $dispatcher): void\n    {\n        if (!$this-\u003eisInterestedInContext($context)) {\n            return;\n        }\n\n        foreach ($this-\u003erepository-\u003efindForMenu() as $entity) {\n            $context-\u003eget('node')\n                -\u003eaddChild()\n                -\u003eset('caption', $entity-\u003egetName())\n                -\u003eset('visible', true)\n                -\u003eset('url', $this-\u003eobjectRouter-\u003epath('detail', $entity));\n        }\n\n        $this-\u003eaddResourcesToTreeCache($dispatcher);\n    }\n\n    private function addResourcesToTreeCache(BuildDispatcher $dispatcher): void\n    {\n        $dispatcher-\u003eaddResource(new FileResource(__FILE__));\n        $dispatcher-\u003eaddResource(new DoctrineEntityClassResource(YourEntity::class));\n    }\n}\n```\n\nDefine your implementation as a service and tag it `webfactory_navigation.build_director`. Example:\n\n```xml\n\u003cservice class=\"AppBundle\\Navigation\\YouEntityBuildDirector\"\u003e\n    \u003cargument type=\"service\" id=\"AppBundle\\Repository\\YourEntityRepository\" /\u003e\n    \u003cargument type=\"service\" id=\"JMS\\ObjectRouting\\ObjectRouter\" /\u003e\n    \u003ctag name=\"webfactory_navigation.build_director\"/\u003e\n\u003c/service\u003e\n```\n\nSee `src/Resources/doc/How-To-Use-Klassendiagramm.puml` for more.\n\n\nCredits, Copyright and License\n------------------------------\n\nThis project was started at webfactory GmbH, Bonn.\n\n- \u003chttps://www.webfactory.de\u003e\n- \u003chttps://twitter.com/webfactory\u003e\n\nCopyright 2015 - 2021 webfactory GmbH, Bonn. Code released under [the MIT license](LICENSE).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebfactory%2Fwebfactorynavigationbundle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwebfactory%2Fwebfactorynavigationbundle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebfactory%2Fwebfactorynavigationbundle/lists"}