{"id":19316248,"url":"https://github.com/userfrosting/grav-plugin-uf-adapter","last_synced_at":"2026-05-17T10:32:19.897Z","repository":{"id":74692141,"uuid":"84491185","full_name":"userfrosting/grav-plugin-uf-adapter","owner":"userfrosting","description":"Adapter to allow you to use your UF templates, assets, and config variables in Grav.","archived":false,"fork":false,"pushed_at":"2018-08-04T17:00:10.000Z","size":16,"stargazers_count":3,"open_issues_count":2,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-01-06T03:43:51.823Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/userfrosting.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,"publiccode":null,"codemeta":null},"funding":{"github":null,"patreon":null,"open_collective":"userfrosting","ko_fi":"lcharette","tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"custom":null}},"created_at":"2017-03-09T21:40:39.000Z","updated_at":"2017-08-26T15:39:03.000Z","dependencies_parsed_at":null,"dependency_job_id":"775d7ff1-253a-45b1-9dde-5ecfb62b6aff","html_url":"https://github.com/userfrosting/grav-plugin-uf-adapter","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/userfrosting%2Fgrav-plugin-uf-adapter","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/userfrosting%2Fgrav-plugin-uf-adapter/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/userfrosting%2Fgrav-plugin-uf-adapter/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/userfrosting%2Fgrav-plugin-uf-adapter/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/userfrosting","download_url":"https://codeload.github.com/userfrosting/grav-plugin-uf-adapter/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240420938,"owners_count":19798501,"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-10T01:10:34.968Z","updated_at":"2026-05-17T10:32:19.819Z","avatar_url":"https://github.com/userfrosting.png","language":"PHP","funding_links":["https://opencollective.com/userfrosting","https://ko-fi.com/lcharette"],"categories":[],"sub_categories":[],"readme":"# Uf Adapter Plugin\n\nThis adapter allows you to use your UF templates, assets, and config variables in [Grav CMS](http://github.com/getgrav/grav). It is implemented as a Grav plugin.\n\nYou can add a Grav blog to your UserFrosting project by creating a `blog/` directory in your main UserFrosting project directory, and then installing Grav to `blog/`:\n\n```bash\nmyUserFrostingProject/\n├── app/\n├── blog/\n|   └── \u003cGrav installation goes here\u003e\n├── build/\n├── licenses/\n├── migrations/\n├── public\n└── webserver-configs/\n```\n\nWhen this plugin is installed to your Grav blog, it will add the following services to Grav's dependency injection container:\n\n- `ufAssets` - UserFrosting's asset loader\n- `ufConfig` - UserFrosting's `Config` object, which contains the [merged result of all config files](https://learn.userfrosting.com/sprinkles/contents#config) from your Sprinkles.\n- `ufLocator` - `UniformResourceLocator` to help find and resolve resources in your Sprinkles.\n\nThe plugin will then use these services to do the following:\n\n- Load UserFrosting templates from any Sprinkles declared in your `sprinkles.json`, into Grav's Twig view.  By default, these will be loaded _before_ any and all Grav templates.  Namespaced template paths for each Sprinkle will also be added (`userfrosting`, `userfrosting.core`, `userfrosting.account`, etc).\n- Add the UserFrosting asset loader to Twig.  Since Grav already has an `assets` Twig variable, UserFrosting's asset loader will be aliased as `ufAssets` in Twig.\n- Merge UserFrosting's `site` config variable into Grav's `site` variable.  Grav's site variables will be overwritten by any with the same name in UserFrosting's config.\n\n## Installation\n\nInstalling the Uf Adapter plugin can be done in one of two ways. The GPM (Grav Package Manager) installation method enables you to quickly and easily install the plugin with a simple terminal command, while the manual method enables you to do so via a zip file.\n\n### GPM Installation (Preferred)\n\nThe simplest way to install this plugin is via the [Grav Package Manager (GPM)](http://learn.getgrav.org/advanced/grav-gpm) through your system's terminal (also called the command line).  From the root of your Grav install type:\n\n    bin/gpm install uf-adapter\n\nThis will install the Uf Adapter plugin into your `/user/plugins` directory within Grav. Its files can be found under `/your/site/grav/user/plugins/uf-adapter`.\n\n### Manual Installation\n\nTo install this plugin, just download the zip version of this repository and unzip it under `/your/site/grav/user/plugins`. Then, rename the folder to `uf-adapter`. You can find these files on [GitHub](https://github.com/alexander-weissman/grav-plugin-uf-adapter) or via [GetGrav.org](http://getgrav.org/downloads/plugins#extras).\n\nYou should now have all the plugin files under\n\n    /your/site/grav/user/plugins/uf-adapter\n\t\n\u003e NOTE: This plugin is a modular component for Grav which requires [Grav](http://github.com/getgrav/grav) and the [Error](https://github.com/getgrav/grav-plugin-error) and [Problems](https://github.com/getgrav/grav-plugin-problems) to operate.\n\n## Configuration\n\nBefore configuring this plugin, you should copy the `user/plugins/uf-adapter/uf-adapter.yaml` to `user/config/plugins/uf-adapter.yaml` and only edit that copy.\n\nHere is the default configuration and an explanation of available options:\n\n```yaml\nenabled: true\n```\n\nNext, you will need to set a `site.uri.main` variable in your **UserFrosting** configuration, so that Grav knows where the main site directory is located.  This is important, because inside Grav, `site.uri.public` will end up pointing to **Grav**'s root url (which is not necessarily the same).\n\nFinally, you will need to add the following dependencies to Grav's `composer.json` file:\n\n```\n    \"require\": {\n        \"userfrosting/assets\": \"^4.0.1\",\n        \"userfrosting/config\": \"^4.0.0\",\n        \"vlucas/phpdotenv\": \"^2\"\n    },\n    \"autoload\": {\n        \"files\": [\n            \"../app/defines.php\",\n            \"../app/helpers.php\"\n        ]\n    }\n```\n\nand then run `composer update` in the `blog/` directory.  Unfortunately, this is the only way to add Composer dependencies to Grav at the moment.\n\n## Usage\n\nYou should create a [Grav theme](https://learn.getgrav.org/themes/theme-basics) that extends the UserFrosting templates imported by this plugin.  For example, you might create a theme that contains the following base template:\n\n```\n{% extends 'layouts/basic.html.twig' %}\n\n{% block stylesheets_site %}\n    \u003c!-- Include main CSS asset bundle --\u003e\n    {{ ufAssets.css() | raw }}\n{% endblock %}\n\n{% block body_matter %}\n    \u003cdiv class=\"row\"\u003e\n        \u003cdiv class=\"col-md-10 col-md-offset-1\"\u003e\n            \u003ch1\u003e{{ page.header.title }}\u003c/h1\u003e\n        \u003c/div\u003e\n    \u003c/div\u003e\n    \u003cdiv class=\"row\"\u003e\n        \u003cdiv class=\"col-md-10 col-md-offset-1\"\u003e\n            {{ page.content }}\n        \u003c/div\u003e\n    \u003c/div\u003e\n{% endblock %}\n\n{% block scripts_site %}\n    \u003c!-- Load jQuery --\u003e\n    \u003cscript src=\"//code.jquery.com/jquery-2.2.4.min.js\" \u003e\u003c/script\u003e\n    \u003c!-- Fallback if CDN is unavailable --\u003e\n    \u003cscript\u003ewindow.jQuery || document.write('\u003cscript src=\"{{ ufAssets.url('assets://vendor/jquery/dist/jquery.min.js', true) }}\"\u003e\u003c\\/script\u003e')\u003c/script\u003e\n\n    {{ ufAssets.js() | raw }}\n{% endblock %}\n```\n\nAs you can see, we've extended UserFrosting's core `layouts/basic.html.twig`, but we've overridden the `stylesheets_site` and `scripts_site` blocks to use the `ufAssets` asset manager variable.  If we didn't do this, the references to `assets` in the base template would resolve to Grav's asset manager instead (which we might not want).\n\n## To Do\n\n- [ ] Figure out how to remove requirement for `site.uri.main` config variable\n- [ ] Maybe alias Grav's asset manager, instead of our own?\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuserfrosting%2Fgrav-plugin-uf-adapter","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fuserfrosting%2Fgrav-plugin-uf-adapter","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fuserfrosting%2Fgrav-plugin-uf-adapter/lists"}