-
Notifications
You must be signed in to change notification settings - Fork 638
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
Feature request: module settings vs. plugin settings #3314
Comments
For now I am able to override the route, since it's a template-route // Register route
Event::on(
UrlManager::class,
UrlManager::EVENT_REGISTER_CP_URL_RULES,
function (RegisterUrlRulesEvent $event) {
$event->rules['settings'] = 'my-module/settings/index';
}
); // Controller action
public function actionIndex(array $variables = [])
{
return $this->renderTemplate('my-module/settings', $variables);
} {% extends 'settings/index' %}
{% block content %}
{{ parent() }}
<hr>
<h2>Modules</h2>
<ul class="icons">
<li>
<a href="">
<div class="icon">
<!-- todo -->
</div>
NAME
</a>
</li>
</ul>
{% endblock %} But a build in feature is quicker I guess |
I think having settings sortof goes against the point of using a module… at that point maybe it would be better off as a plugin. If you really want it to be a module, you can define settings in a utility. |
Hm okay, but if it is about project specific code, it shouldn't be a plugin, that's the beauty of modules, they are always there and no option to uninstall. But somehow you should be able to define settings, and you should be able to create settings which can be modified. Now using above solution, which is working fine. Together with using the system settings // getting it
$settings = \Craft::$app->getSystemSettings()->getSettings('my-module');
// do things...
// setting at save
\Craft::$app->getSystemSettings()->saveSettings('my-module', $settings); Works good. |
Yeah OK fair enough. I can add an event to |
Sounds like a plan 😄 thanks 👍 |
I also understand your point of modules, but that's such a great improvement for project's codebase instead of plugins. Really love that feature. So a little base class to speed up development could not hurt in my opinion. But maybe in the future. |
Added this for the next Craft 3.1 release. |
Realise I've missed the boat on this thread, but as a sub-par PHP developer I would love an option to create a settings page for modules that was less involved. |
@brandonkelly I know this is very old but would it be possible to expand on this and also the use of |
@ArtDepartmentMJ Just updated the event docs with an example. |
Description
I know modules are not plugins, but sometimes you want to add configurable settings for your module, so the client can adjust the module to their needs.
I also know that it's possible to create your own section. But that's weird in some situations.
For example;
A lot of the time I create a "members" module, which contains a customizations on top of users. Because the client wants some special stuff, relational data, external parties linked to users etc. etc.
In this case I do not want an extra navigation item on the left, but just an extra settings icon/button to give the client the ability to change the module's behavior.
Another example;
My "members" plugin does add a couple of notifications about things that happen. I want my client to be able to change the notification email address or let him toggle things to notify about etc. etc.
Solution
A simple solution would be to create an event on the Settings-dashboard to add-in new custom buttons.
Another solution is to register modules as plugins of type "module" (in the plugins table). The pro for this is, you can use the settings like plugins can do too.
Like to hear your point of view.
The text was updated successfully, but these errors were encountered: