Now you can only specify what plugins your theme depends on. It doesn't make sense for theme authors to bake in support for every popular plugin if it pulls in all those dependencies as well. However, a theme might have support for it but not require it. This would need a mechanism for themes to check if a plugin is activated and then include code.
This would also be a huge benefit to the theme marketplace since the users can search for themes that supports RainLab.Blog, for example.
If a theme supports a plugin, but does not require it, it should not include that plugin in the require definition. However, the front end page will crash if a component is used that doesn't exist (this is desirable). So we need to add "soft" component implementation definitions like this
[@someComponent]
willNot = "fail if missing"
[\Full\Path\To\Component @softFail]
==
{% if someComponent %}
<p>The plugin with someComponent is installed!</p>
{% else %}
<p>Do something else...</p>
{% endif %}
The above code instructions are simple: prefix the component alias with an @ symbol and it will not cause the page to crash if the component is not found. This will allow themes to have optional support for plugin functionality.
@daftspunk I tried escape using the @ while importing a component, but it didn't work. the page would throw
An exception has been thrown during the rendering of a template ("Class name is not registered for the component "@SeoCmsPage". Check the component plugin.").
@scazzy @daftspunk was describing how it should work, not how it does work unfortunately. That feature hasn't been implemented yet.
Let me know what do you think about this approach:
https://github.com/viamage/october/pull/1/files
Works properly
http://uploads.keios.eu/video/october-softcomponents.html
but we could go deeper into makeComponent and soft-check only there, or maybe don't go with catch at all and do it differently?
@viamage could you make the PR to this repo so we can review it in a PR here instead?
Sure, made at https://github.com/octobercms/october/pull/3577
Keep in mind it's just a proposal that requires feedback, thus I hesitated from making it a PR here before.
This issue will be closed and archived in 3 days, as there has been no activity in the last 30 days. If this issue is still relevant or you would like to see action on it, please respond and we will get the ball rolling.
Implemented by https://github.com/octobercms/october/pull/4539.
Most helpful comment
If a theme supports a plugin, but does not require it, it should not include that plugin in the require definition. However, the front end page will crash if a component is used that doesn't exist (this is desirable). So we need to add "soft" component implementation definitions like this
The above code instructions are simple: prefix the component alias with an
@symbol and it will not cause the page to crash if the component is not found. This will allow themes to have optional support for plugin functionality.