Object templates
The handle and path of a namespace are object templates. These variables are available:
| Variable | Description |
|---|---|
site |
The current site. |
group |
The group of the current site, or null. |
| … | Any variable from the context of the namespace. |
A namespace whose path renders empty is skipped, and so is the handle if it renders empty.
Change the context of a namespace in code with the EVENT_NAMESPACE_CONTEXT event:
use SomehowDigital\Craft\Stack\events\NamespaceContextEvent;use SomehowDigital\Craft\Stack\Stack;use yii\base\Event;
Event::on( Stack::class, Stack::EVENT_NAMESPACE_CONTEXT, function (NamespaceContextEvent $event): void { $event->context['env'] = 'staging'; },);$event->namespace holds the configuration of the namespace being resolved.