{"id":18496940,"url":"https://github.com/shapecode/theme-bundle","last_synced_at":"2025-05-14T04:36:25.220Z","repository":{"id":57048927,"uuid":"122335381","full_name":"shapecode/theme-bundle","owner":"shapecode","description":null,"archived":false,"fork":false,"pushed_at":"2019-07-22T08:36:28.000Z","size":19,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-05-14T04:34:38.424Z","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/shapecode.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-02-21T12:46:39.000Z","updated_at":"2019-07-22T08:36:30.000Z","dependencies_parsed_at":"2022-08-23T19:10:28.513Z","dependency_job_id":null,"html_url":"https://github.com/shapecode/theme-bundle","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/shapecode%2Ftheme-bundle","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shapecode%2Ftheme-bundle/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shapecode%2Ftheme-bundle/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/shapecode%2Ftheme-bundle/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/shapecode","download_url":"https://codeload.github.com/shapecode/theme-bundle/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254071492,"owners_count":22009798,"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-06T13:32:37.658Z","updated_at":"2025-05-14T04:36:25.202Z","avatar_url":"https://github.com/shapecode.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"Theme Bundle\n============\n\nThis bundle provides you the possibility to add themes to each bundle. In your\nbundle directory it will look under `Resources/themes/\u003cthemename\u003e` or fall back\nto the normal Resources/views if no matching file was found.\n\n## Installation\n\nInstallation is a quick (I promise!) 3 step process:\n\n1. Download ShapecodeThemeBundle\n2. Enable the Bundle\n\n### Step 1: Install ShapecodeThemeBundle with composer\n\nRun the following composer require command:\n\n``` bash\n$ php composer.phar require shapecode/theme-bundle\n\n```\n\n### Step 2: Enable the bundle\n\nFinally, enable the bundle in the kernel:\n\n``` php\n\u003c?php\n// app/AppKernel.php\n\npublic function registerBundles()\n{\n    $bundles = array(\n        // ...\n        new \\Shapecode\\Bundle\\ThemeBundle\\ShapecodeThemeBundle(),\n    );\n}\n```\n\n## Configuration\n\nYou will have to set your possible themes and the currently active theme. It\nis required that the active theme is part of the themes list.\n\n``` yaml\n# app/config/config.yml\nshapecode_theme:\n    themes: ['standardTheme', 'winter_theme', 'weekend']\n    active_theme: 'standardTheme'\n```\n\n### Get active theme information from cookie\n\nIf you want to select the active theme based on a cookie you can add:\n\n``` yaml\n# app/config/config.yml\nshapecode_theme:\n    cookie:\n        name: NameOfTheCookie\n        lifetime: 31536000 # 1 year in seconds\n        path: /\n        domain: ~\n        secure: false\n        http_only: false\n```\n\n\n### Theme Cascading Order\n\nThe following order is applied when checking for templates that live in a bundle, for example `@BundleName/Resources/template.html.twig`\nwith theme name ``phone`` is located at:\n\n1. Override themes directory: `app/Resources/themes/phone/BundleName/template.html.twig`\n2. Override view directory: `app/Resources/BundleName/views/template.html.twig`\n3. Bundle theme directory: `src/BundleName/Resources/themes/phone/template.html.twig`\n4. Bundle view directory: `src/BundleName/Resources/views/template.html.twig`\n\nFor example, if you want to integrate some TwigBundle custom error pages regarding your theme\narchitecture, you will have to use this directory structure :\n`app/Resources/themes/phone/TwigBundle/Exception/error404.html.twig`\n\nThe following order is applied when checking for application-wide base templates, for example `::template.html.twig`\nwith theme name ``phone`` is located at:\n\n1. Override themes directory: `app/Resources/themes/phone/template.html.twig`\n2. Override view directory: `app/Resources/views/template.html.twig`\n\n#### Change Theme Cascading Order\n\nYou able change cascading order via configurations directives: `path_patterns.app_resource`, `path_patterns.bundle_resource`, `path_patterns.bundle_resource_dir`. For example:\n\n``` yaml\n# app/config/config.yml\nshapecode_theme:\n    path_patterns:\n        app_resource:\n            - %%app_path%%/themes/%%current_theme%%/%%template%%\n            - %%app_path%%/themes/fallback_theme/%%template%%\n            - %%app_path%%/views/%%template%%\n        bundle_resource:\n            - %%bundle_path%%/Resources/themes/%%current_theme%%/%%template%%\n            - %%bundle_path%%/Resources/themes/fallback_theme/%%template%%\n        bundle_resource_dir:\n            - %%dir%%/themes/%%current_theme%%/%%bundle_name%%/%%template%%\n            - %%dir%%/themes/fallback_theme/%%bundle_name%%/%%template%%\n            - %%dir%%/%%bundle_name%%/%%override_path%%\n```\n\n##### Cascading Order Patterns Placeholders\n\n\u003ctable\u003e\n  \u003ctr\u003e\n    \u003cth\u003ePlaceholder\u003c/th\u003e\n  \u003cth\u003eRepresentation\u003c/th\u003e\n  \u003cth\u003eExample\u003c/th\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd\u003e\u003ccode\u003e%app_path%\u003c/code\u003e\u003c/td\u003e\n  \u003ctd\u003ePath where application resources are located\u003c/td\u003e\n  \u003ctd\u003e\u003ccode\u003eapp/Resources\u003c/code\u003e\u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd\u003e\u003ccode\u003e%bundle_path%\u003c/code\u003e\u003c/td\u003e\n  \u003ctd\u003ePath where bundle located, for example\u003c/td\u003e\n  \u003ctd\u003e\u003ccode\u003esrc/Vendor/CoolBundle/VendorCoolBundle\u003c/code\u003e\u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd\u003e\u003ccode\u003e%bundle_name%\u003c/code\u003e\u003c/td\u003e\n  \u003ctd\u003eName of the bundle\u003c/td\u003e\n  \u003ctd\u003e\u003ccode\u003eVendorCoolBundle\u003c/code\u003e\u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd\u003e\u003ccode\u003e%dir%\u003c/code\u003e\u003c/td\u003e\n  \u003ctd\u003eDirectory, where resource should looking first\u003c/td\u003e\n  \u003ctd\u003e\u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd\u003e\u003ccode\u003e%current_theme%\u003c/code\u003e\u003c/td\u003e\n  \u003ctd\u003eName of the current active theme\u003c/td\u003e\n  \u003ctd\u003e\u003c/td\u003e\n  \u003c/tr\u003e\n    \u003ctd\u003e\u003ccode\u003e%template%\u003c/code\u003e\u003c/td\u003e\n  \u003ctd\u003eTemplate name\u003c/td\u003e\n  \u003ctd\u003e\u003ccode\u003eview.html.twig\u003c/code\u003e\u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd\u003e\u003ccode\u003e%override_path%\u003c/code\u003e\u003c/td\u003e\n  \u003ctd\u003eLike template, but with views directory\u003c/td\u003e\n  \u003ctd\u003e\u003ccode\u003eviews/list.html.twig\u003c/code\u003e\u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\n\n### Change Active Theme\n\nFor that matter have a look at the ThemeRequestListener.\n\nIf you are early in the request cycle and no template has been rendered you\ncan still change the theme without problems. For this the theme service\nexists at:\n\n``` php\n$activeTheme = $container-\u003eget('shapecode_theme.active_theme');\necho $activeTheme-\u003egetName();\n$activeTheme-\u003esetName(\"phone\");\n```\n\n## Contribution\n\nActive contribution and patches are very welcome. \n\nFirst install dependencies:\n\n```bash\n   composer.phar install --dev\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshapecode%2Ftheme-bundle","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fshapecode%2Ftheme-bundle","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fshapecode%2Ftheme-bundle/lists"}