PHPackages                             somehow-digital/craft-stack - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Templating &amp; Views](/categories/templating)
4. /
5. somehow-digital/craft-stack

ActiveCraft-plugin[Templating &amp; Views](/categories/templating)

somehow-digital/craft-stack
===========================

Brings a namespace system to better organize and load Twig templates in Craft CMS.

v1.1.0(3mo ago)181[1 issues](https://github.com/somehow-digital/craft-stack/issues)MITPHPPHP ^8.2

Since Mar 27Pushed 3mo agoCompare

[ Source](https://github.com/somehow-digital/craft-stack)[ Packagist](https://packagist.org/packages/somehow-digital/craft-stack)[ Docs](https://somehow.digital/)[ RSS](/packages/somehow-digital-craft-stack/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (2)Dependencies (4)Versions (3)Used By (0)

[![Stack Logo](src/icon.svg)](src/icon.svg)

`Stack` for Craft CMS
=====================

[](#stack-for-craft-cms)

> Brings a namespace system to better organize and load [Twig](https://twig.symfony.com/) templates in [Craft CMS](https://craftcms.com/).

`Stack` provides a namespace system to resolve template files and behaves similar to how Twig's native [FilesystemLoader](https://twig.symfony.com/doc/3.x/api.html#twig-loader-filesystemloader) works. Under the hood it uses Craft's [Template Roots](https://craftcms.com/docs/5.x/extend/template-roots.html) mechanism. Currently, this plugin works in frontend mode only. (It does not work with Craft's panel templates.)

Requirements
------------

[](#requirements)

- Craft CMS 5.8.0 or later.
- PHP 8.2 or later.

Installation
------------

[](#installation)

Install this plugin from the Plugin Store or via Composer.

#### Plugin Store

[](#plugin-store)

Go to the “Plugin Store” in your project’s Control Panel, search for “stack” and click on the “Install” button in its modal window.

#### Composer

[](#composer)

```
composer require somehow-digital/craft-stack
./craft plugin/install stack
```

Configuration
-------------

[](#configuration)

Settings can be configured via a `config/stack.php` config file.

> **`prefix`** - handle prefix for namespaced template file paths.

*default*: `@`

> **`namespaces`** - list of namespaces for template file path resolution.

*default*: `[]`

- By default, no namespaces are configured, and the plugin will not resolve templates.
- Order of namespaces matters when template file paths are resolved via `Dynamic Resolution`.
- `handle` and `path` values can use object templates, where `Site` (`site`) and `SiteGroup` (`group`) objects are available to use.
- `handle` values are optional but are needed if `Static Resolution` is to be used.
- `context` values are optional and are used to pass variables to be used in object templates.

**config/stack.php**

```
