Skip to content

[FR] Site group-based templates #8564

Closed Answered by brandonkelly
hongc-cc asked this question in Ideas
Discussion options

You must be logged in to vote

We have decided not to implement this feature.

In addition to @Anubarak’s symlink-based solution, another way you can approach this is with a custom _siteGroup template root, defined by a bootstrapped module or private plugin:

use Craft;
use craft\events\RegisterTemplateRootsEvent;
use craft\helpers\StringHelper;
use craft\web\View;
use yii\base\Event;

Event::on(
    View::class,
    View::EVENT_REGISTER_SITE_TEMPLATE_ROOTS,
    function(RegisterTemplateRootsEvent $event) {
        $site = Craft::$app->sites->getCurrentSite();
        $group = StringHelper::toCamelCase($site->getGroup()->name);
        $event->roots['_siteGroup'] = Craft::getAlias("@templates/_siteGroups/$group");
    }
);

Replies: 13 comments 15 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
3 replies
@brandonkelly
Comment options

@jan-dh
Comment options

@zehfred
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@brandonkelly
Comment options

@jan-dh
Comment options

Comment options

You must be logged in to vote
2 replies
@brandonkelly
Comment options

@jannisborgers
Comment options

Comment options

You must be logged in to vote
8 replies
@jan-dh
Comment options

@brandonkelly
Comment options

@jan-dh
Comment options

@brandonkelly
Comment options

@jan-dh
Comment options

Answer selected by brandonkelly
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Ideas
Labels
enhancement improvements to existing features sites 🌎 features related to multi-site
10 participants
Converted from issue

This discussion was converted from issue #3101 on June 22, 2021 06:21.