Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add attributes to the Site config #3996

Merged
merged 2 commits into from
Jul 15, 2021
Merged

Conversation

RafaelKr
Copy link
Contributor

@RafaelKr RafaelKr commented Jul 14, 2021

Closes statamic/ideas#602

If this is accepted, I can also update the docs before it will be merged.

now you can define site-specific attributes in your config/statamic/sites.php
This is useful if you want to define different themes per site for example.

<?php

return [
    'sites' => [
        'default' => [
            'name' => config('app.name'),
            'locale' => 'en_US',
            'url' => '/',

            'attributes' => [
                'theme' => 'default',
            ],
        ]
    ]
];

This can now be used to set a class:

<body class="theme-{{ site:attributes:theme }}">
    <!-- [...] -->
</body>

now you can define site-specific `attributes` in your config/statamic/sites.php
This is useful if you want to define different themes per site for example.

```php
<?php

return [
    'sites' => [
        'default' => [
            'name' => config('app.name'),
            'locale' => 'en_US',
            'url' => '/',

            'attributes' => [
                'theme' => 'default',
            ],
        ]
    ]
];
```

This can now be used to set a class:
```html
<body class="theme-{{ site:attributes:theme }}">
    <!-- [...] -->
</body>
```
@jasonvarga
Copy link
Member

jasonvarga commented Jul 14, 2021

Part of me wants to be able to just add anything to the array instead of using a sub attributes array.
But maybe the attributes array will let us avoid potential variable conflicts in the future.

Probably better to have an attributes array, like you've done. 👍

@RafaelKr
Copy link
Contributor Author

RafaelKr commented Jul 14, 2021

@jasonvarga exactly my thought. I first tried to just add it at top-level and wondered why it wasn't working. Then I've read the docs again and saw there are only those pre-defined config options.

It definitely prevents name clashes, if you need to add more required options in the future. So you would add it like this?
I can write the docs if you'd like me to, but I also don't mind if you do it, you get paid for it anyway :P

Edit: Ah I see there are failing tests. I'll have a look at it later.

@jasonvarga jasonvarga merged commit c4ea428 into statamic:3.1 Jul 15, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Multisite custom config keys
2 participants