{"id":20779303,"url":"https://github.com/bolt/base-widget","last_synced_at":"2026-03-27T02:16:02.761Z","repository":{"id":146895344,"uuid":"45335956","full_name":"bolt/base-widget","owner":"bolt","description":"A basic widget extension, to insert static blocks, rendered templates, or specific content.","archived":false,"fork":false,"pushed_at":"2018-09-23T09:46:04.000Z","size":36,"stargazers_count":4,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-12-26T18:48:07.012Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"HTML","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bolt.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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,"publiccode":null,"codemeta":null}},"created_at":"2015-11-01T10:20:18.000Z","updated_at":"2019-10-03T22:20:54.000Z","dependencies_parsed_at":null,"dependency_job_id":"e4ec2686-b912-4a9e-a68e-dd8d6221080f","html_url":"https://github.com/bolt/base-widget","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"purl":"pkg:github/bolt/base-widget","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bolt%2Fbase-widget","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bolt%2Fbase-widget/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bolt%2Fbase-widget/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bolt%2Fbase-widget/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bolt","download_url":"https://codeload.github.com/bolt/base-widget/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bolt%2Fbase-widget/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31009857,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-27T01:56:05.093Z","status":"online","status_checked_at":"2026-03-27T02:00:08.055Z","response_time":164,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":[],"created_at":"2024-11-17T13:27:10.410Z","updated_at":"2026-03-27T02:16:02.201Z","avatar_url":"https://github.com/bolt.png","language":"HTML","funding_links":[],"categories":[],"sub_categories":[],"readme":"Bolt Base Widget\n================\n\nUsing this extension, you can easily configure and add widgets to a Bolt\nwebsite. This can be done both in the 'frontend' as well as in the backend.\n\nThis allows you to define specific 'blocks' for your website that don't really\nfit into anything else, or you can use it to render and cache parts of the page\nthat are slowing down the performance. By adding these as a 'cached' or\n'deferred' widget, the page will no longer slow down while waiting for all of\nthe content to render.\n\nSome of the features of this extension are:\n\n - Adding a widget with static, predefined content\n - Adding widgets that retrieve a specific record\n - Using templates to render widgets\n - Widgets can be added to both the 'frontend' and 'backend'\n - Widgets can be cached and rendered non-blocking (deferred)\n\nThis extension uses Bolt's widget functionality. For the various locations that\nyou can add widgets, you'll find an [updated list][1] on the Bolt documentation\nwebsite.\n\nTo get a good idea of the possibilities of this extension, simply check out the\n[default configuration][2], which shows various types of widgets to add.\n\nOptions:\n\n - `location`: The location determines where the widget will be inserted in the\n   template. For the backend there are a number of pre-defined positions, but\n   for the frontend this depends on where the theme's author has provided\n   `{{ widget() }}` areas.\n - `zone`: Use this to specify a widget for 'backend'. If you omit this option,\n   it'll be inserted in the 'frontend' by default.\n - `record`: Specify If the `content` option is also used, it will be used as a\n   fallback for the values of `{{ record }} `\n - `template`: Define the template to use for rendering this widget. See the\n   section 'Overriding the templates' below.\n - `content`: The content defines the static content for the widget and is\n   normally defined as an array. This will be passed into the widget as-is, and\n   will be accessible in the widget's template as `{{ content }}`. For backend\n   widgets, there's a pre-defined format for this. See the section 'backend\n   widgets' below.\n - `enabled`: Use this option to (temporarily) disable a widget. If set to\n   `enabled: false`, the widget will not be shown anywhere.\n - `defer`: Insert this widget using 'ajaxy loading'. The page is rendered with\n   an empty placeholder for the widget, which is then rendered in a separate\n   request, and inserted in the page.\n - `cacheduration`: The amount (in seconds) that the entire widget is cached on\n   the server. This can significantly speed up the rendering of pages, but be\n   aware that _cached_ widgets can not show tailored content. The widget will\n   show the same on every page, for all visitors.\n - `withcontext`: By design, widgets are \"without context\", because in normal\n   use, the contents of a widget should _not_ depend on the page it's rendered\n   on. Sometimes, however, you might really need this context. Setting\n   `withcontext: true` will make sure your widget knows about all defined Twig\n   variables that were available in the surrounding page, like\n   `{{ dump(record) }}` in the front- or `{{ dump(context) }}` in the backend.\n   Note that if you use this option, `cacheduration` and `defer` will both be\n   disabled for this specific widget, so use with care and thought.\n - `priority`: Use this to specify the order in which widgets are displayed.\n   Higher priorities are displayed first.\n\nOverriding the templates\n------------------------\nThis extension comes with a few default `.twig` files, to render blocks of\ncontent or backend widgets. Especially if you are using this extension to add\nblocks to your frontend pages, chances are that you will want to modify the way\nit looks.\n\nIn one of the stock examples, you'll see:\n\n```\ntemplate: widgets/contentblock.twig\n```\n\nThis uses the template at`basewidget/widgets/templates/contentblock.twig`, in\nthe `extensions/vendor/bolt` folder. If you wish to use your own template,\nsimply create a folder `widgets` in your current theme directory, and copy the\nfile `contentblock.twig` to it. Bolt will automatically pick up the one from\nyour own theme, if you've overridden it.\n\nObviously you can also give a widget another template to render, but it is good\npractice to keep these organized in a `widgets/` folder inside your theme.\n\nBackend widgets\n---------------\n\nUsing this extension, you'll be able to easily add two types of widgets to the\nBolt backend:\n\n - Panel widgets, for the sidebars on 'Dashboard', 'Overview listing', and\n   'Edit content' pages.\n - Button widgets, for almost all pages.\n\nTo add a button to the Dashboard, use the following:\n\n```\n    block6:\n        type: backend\n        location: dashboard_below_header\n        template: widgets/backend_buttons.twig\n        content:\n            buttons:\n                About:\n                    type: secondary\n                    icon: heart\n                    path: about\n```\n\nThis is the result:\n\n![screenshot 1][img1]\n\n\nThe `location` is one of the pre-defined locations in Bolt's backend where you\ncan add widgets. The `content` has a field `buttons`, that defines one or more\nbuttons. In the above example, only one button is added, that's labeled\n'About'. To determine the functionality of the buttons, there are four options:\n\n - `type`: Specify the type of button. Accepted values are `primary`,\n   `secondary`, `tertiary` and `default`. When adding multiple buttons, you\n   should take care not to make the interface too cluttered by having too many\n   \"primary\" button. Ideally, you'd add one \"primary\" button at most, and any\n   others should bet either \"tertiary\" or \"default\".\n - `icon`: This can be any [Font Awesome][fa] icon. If omitted, the button will\n   have no icon.\n - `path`: Specify a named path, as defined by `-\u003ebind('…')` in the controller.\n   This will mostly be useful if you have created an extension, and would like\n   to add some buttons for it. If this is used, it takes priority over the\n   `link` option.\n - `link`: This can be either an internal (relative) or an external (absolute)\n   link to any URL you'd like.\n - `target`: Set this to `_blank` in order to open the specified link in a new\n   tab/window in the browser.\n\n\nTo add a panel widget to the backend, use the following structure:\n\n```\n    block5:\n        type: backend\n        location: dashboard_aside_top\n        template: widgets/backend_panel.twig\n        content:\n            icon: camera-retro\n            title: An example of a Dashboard widget\n            description: \"Lorem ipsum dolor sit amet … …\"\n            buttons:\n                About:\n                    type: primary\n                    icon: heart\n                    path: about\n                Documentation:\n                    type: default\n                    icon: leanpub\n                    link: 'https://docs.bolt.cm'\n                    target: '_blank'\n```\n\nThe result will look like this:\n\n![screenshot 2][img2]\n\nAs before, you'll note the section with \"buttons\". These have the same options\nas before. This widget has some additional fields, like `icon`, `title` and\n`description`, which should all be self explanatory.\n\n\n[1]: https://docs.bolt.cm/extensions/intermediate/widgets#locations\n[2]: https://github.com/bolt/base-widget/blob/master/config/config.yml.dist\n[fa]: http://fontawesome.io/icons/\n[img2]: https://cloud.githubusercontent.com/assets/1833361/10868858/3e93eca6-809c-11e5-8212-179f909cf94d.png\n[img1]: https://cloud.githubusercontent.com/assets/1833361/10868978/e0f4bfd6-809f-11e5-9119-c2bf6a4e7d47.png\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbolt%2Fbase-widget","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbolt%2Fbase-widget","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbolt%2Fbase-widget/lists"}