{"id":20075459,"url":"https://github.com/validoll/token_views_filter","last_synced_at":"2025-05-05T21:33:13.171Z","repository":{"id":81416989,"uuid":"109812908","full_name":"validoll/token_views_filter","owner":"validoll","description":"This is module allow to use tokens in views filter criteria values.","archived":false,"fork":false,"pushed_at":"2024-02-12T10:19:10.000Z","size":46,"stargazers_count":5,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"2.x","last_synced_at":"2025-04-09T04:51:15.575Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","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/validoll.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}},"created_at":"2017-11-07T09:17:54.000Z","updated_at":"2024-02-12T10:18:42.000Z","dependencies_parsed_at":null,"dependency_job_id":"51856322-bb09-4105-bbfa-d190cfb38c96","html_url":"https://github.com/validoll/token_views_filter","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/validoll%2Ftoken_views_filter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/validoll%2Ftoken_views_filter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/validoll%2Ftoken_views_filter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/validoll%2Ftoken_views_filter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/validoll","download_url":"https://codeload.github.com/validoll/token_views_filter/tar.gz/refs/heads/2.x","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252580116,"owners_count":21771265,"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":[],"created_at":"2024-11-13T14:59:29.349Z","updated_at":"2025-05-05T21:33:08.162Z","avatar_url":"https://github.com/validoll.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Tokens in Views Filter Criteria\n\n## ★★★ GITHUB ★★★\n\n**If you like the module please give a STAR on\nGitHub project page https://github.com/validoll/token_views_filter.**\n\n## INTRODUCTION\nThe Tokens in Views Filter Criteria module allow to use tokens in views\n**string, numeric and date** filter criteria values.\n\n * For a full description of the module, visit the project page:\n   https://www.drupal.org/project/token_views_filter\n\n * To submit bug reports and feature suggestions, or to track changes:\n   https://www.drupal.org/project/issues/token_views_filter\n\n## REQUIREMENTS\nThis module has no specific requirements outside Drupal core.\n\n## INSTALLATION\nInstall as you would normally install a contributed Drupal module. Visit:\nhttps://www.drupal.org/documentation/install/modules-themes/modules-8\nfor further information.\n\n## CONFIGURATION\nOpen any target view and open settings form of any string or numeric filter.\nThen check field \"Use tokens in value\" in settings form and add global\ntokens to filter value.\n\n## FOR DEVELOPERS\nYou can use your own plugins to implement token views filters via Token\nViews Filter Plugin manager.\nTo create plugin put it to `src/Plugin/views/filter/token` folder and define\nwith ID as original views filter plugin, like\n\n```\n/**\n * @Plugin(\n *   id = \"string\",\n * )\n */\n```\n\nA plugin should extend class of original views filter plugin, implements\n`Drupal\\token_views_filter\\TokenViewsFilterPluginInterface` and uses trait\n`Drupal\\token_views_filter\\TokensFilterTrait`.\nUse `replaceTokens()` method to replace tokens in value.\n\n### Example\n\n```\n\u003c?php\n\nnamespace Drupal\\token_views_filter\\Plugin\\views\\filter\\token;\n\nuse Drupal\\token_views_filter\\TokensFilterTrait;\nuse Drupal\\token_views_filter\\TokenViewsFilterPluginInterface;\nuse Drupal\\views\\Plugin\\views\\filter\\StringFilter;\n\n/**\n * Extending basic string filter to use tokens as value.\n *\n * @Plugin(\n *   id = \"string\",\n * )\n */\nclass TokensStringFilter extends StringFilter implements TokenViewsFilterPluginInterface {\n\n  use TokensFilterTrait;\n\n  /**\n   * {@inheritdoc}\n   */\n  public function replaceTokens() {\n    $this-\u003evalue = $this-\u003etoken-\u003ereplace($this-\u003evalue, ['view' =\u003e $this-\u003eview], ['clear' =\u003e TRUE]);\n  }\n\n}\n```\n\n### Schema definition\n\nTo use token views filter you should redefine original views filter schema\nin your module in file `config/schema/{module_name}.schema.yml`\n\nFor example:\n\n```\nviews.filter.string:\n  type: views_filter\n  label: 'String'\n  mapping:\n    expose:\n      type: mapping\n      label: 'Exposed'\n      mapping:\n        required:\n          type: boolean\n          label: 'Required'\n        placeholder:\n          type: label\n          label: 'Placeholder'\n    value:\n      type: string\n      label: 'Value'\n    use_tokens:\n      type: boolean\n      label: 'Use tokens'\n```\n\nYou should add\n\n```\n    use_tokens:\n      type: boolean\n      label: 'Use tokens'\n```\n\nto mapping of plugin.\n\n## KNOWN ISSUES\n\nIf you know how to override definition of original views filter\nto add `use_tokens` property. Pls see\nhttps://www.drupal.org/project/token_views_filter/issues/3083793\nfor more details.\n\n## MAINTAINERS\n\n * Vyacheslav Malchik (validoll) - https://www.drupal.org/u/validoll\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvalidoll%2Ftoken_views_filter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvalidoll%2Ftoken_views_filter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvalidoll%2Ftoken_views_filter/lists"}