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
Ability to override Component partials (Cherry pick method) #41
Comments
Superseded by #44 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Some Plugins can have many interconnecting partial references. This can become an issue when a theme wants to change a single partial in a component. At the moment the plugin's entire partial structure must be rebuilt in the theme up until the point the partial is used.
Concept one
Let's take the Plugin called Forum for example, with a component named Channel, it has these partials:
And look at the code inside
default.htm
:Let's say a user wants to override the title partial only. As a component developer, I can predict this and make room for it. If I change the partial code to this:
By using this code instead, we will say:
There is one problem with this scenario, the name "title" is too generic. It should be called "forum_channel_title" instead, but let's ignore that and keep it simple for now.
Concept two
But what if we don't want the partial to overriden by the theme, I like the idea of using short partial names. This can be possible by forcing the CMS to look at Components first, not the Theme.
The
@
symbol is responsible for this here. It will translate to::pagination
, when the component name is missing like this, all available components will be scanned. This is a "relaxed" approach.However, to avoid conflicts with other components, a strict approach can be used, like so:
This is not as pretty, but it explicitly defines the component alias and will eliminate the possibility of another component used on a page or layout that also has a partial called pagination.
Concept three
Extending concept one, it can still be possible to override a component on the basis of it's alias.
Take this page code for example, the same component is used twice, with a separate alias, and separate config.
This is how we can override title.htm in this scenario, inside the theme /partials folder:
We can cherry pick the partial, based on the alias given to the component.
The text was updated successfully, but these errors were encountered: