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

Allow custom development using model and controller overrides #252

Open
aDaneInSpain opened this issue Feb 18, 2018 · 14 comments
Open

Allow custom development using model and controller overrides #252

aDaneInSpain opened this issue Feb 18, 2018 · 14 comments

Comments

@aDaneInSpain
Copy link
Owner

One of the most popular feature requests we get, is to enable some form of functionality, that would allow people to generate a component, modify the code, go back to component creator, make changes, generate a new version, and then somehow keep the first manual changes to the code.

We have previously considered some form of version control, that would allow you to merge your code, but it has proven to be as complicated, or more complicated than running your own version control and doing it manually, and it would be a huge development task for us.

Today a user gave us the idea of making it possible to make overrides to the Model or Controllers. You can already override views using Joomla so we will not deal with those.

So we would like to hear what people think about this idea and would love input into how this should be implemented to be as flexible and user friendly as possible.

@go-source
Copy link

The idea sounds good. I just want to add that triggers to plugins 'on before' and 'on after' would let me do a lot of custom code without changing the model or the controller. The default code I've got from component creator triggers some plugins in the back-end but not in the front-end, so I had to change the model or the table to accomplish what I could have done with plugins.

@gdpodesta
Copy link

Triggers and Overrides (IMHO) would make CC the standard in your market. Before I go on, let me be clear that I LOVE CC - it has saved me hundreds of hours, but it only does the framework.

Once I believe that I have all my data laid out, i can create that framework, but making my component anywhere nearly complete always involves adding a lot of jQuery, AJAX, integrations, and application specific changes to the model. Once I begin that, I can no longer generate the code without losing my app code and logic, and so (sadly) my need for CC is halted.

Additionally, the overrides would allow customization for specific installations without changing the core code of the finished product. This, to me, is a major shortcoming of the standard Joomla view overrides using the template folder. If a site changes templates, all the customization have to be revisited as well.

@aDaneInSpain
Copy link
Owner Author

OK. If you can provide more precise details as to what triggers we need to implement, then I think we can implement those relatively fast with the override functionality coming later.

@go-source
Copy link

Trigger: https://docs.joomla.org/Supporting_plugins_in_your_component
Include this in the default frontend model
https://docs.joomla.org/Plugin/Events/System
https://docs.joomla.org/Plugin/Events

Example: If I have "OnContentBeforeSave" I can write a plugin that changes the data before save. I do not have to change the model, I can maintain my code in the plugin: easier to maintain. Consider all other possibilities with Events

@gdpodesta
Copy link

gdpodesta commented Feb 26, 2018 via email

@gdpodesta
Copy link

gdpodesta commented Feb 26, 2018 via email

@GeoTimber
Copy link

+1 Yes overrides of any of the controller/models/helpers/table/... classes etc would be great to keep code organized and make components more reusable, even better if we can just override a method by using class extensions.

I occasionally use class overrides/extensions in a system plugin based on the ideas from https://github.com/redCOMPONENT-COM/mvcOverride

thanks!

@aDaneInSpain
Copy link
Owner Author

@CarlFuentes2020 @emmanuel-tsalampounis let's have a meeting about this once the dust settles on J4 compatibility and see if we can solve this

@blueline86
Copy link

I've always wanted this feature, but I too struggle to think how it would be practically rolled out. One (probably bad) solution would be to let the user override ANY file that is generated. They can at all times view the automatically generated version as well and see tracked changes between the files so the changes they have made (and the parts they are missing) are obvious.

Code that is in the auto-generated page but not in the custom one could be red and Code that is in the custom page but not the auto page could be in blue. The user can of course turn that on or off, switching between an unadulterated custom, unadulterated auto, and tracked versions of both.

The user can package the component as is and will have to deal with errors they create - but they can of course always roll back to the auto-generated version of any page.

You may also want to add some auto versioning on save with such a feature.

@blueline86
Copy link

Also, something to consider is allowing users to add extra files that don't exist by default. My thinking is custom fields and layouts. I would happily extend the Foreignkey field and add a few totally custom ones and J4 is moving towards using lots of layouts.

@emmanuel-tsalampounis emmanuel-tsalampounis removed their assignment May 17, 2021
@EvDoorne
Copy link

EvDoorne commented Aug 4, 2021

The issues you outline in the initial post are the main reason why we sometimes (have to) refrain from using CC and go for alternative solutions.

@aDaneInSpain
Copy link
Owner Author

@CarlFuentes2020 I think the time has come to tackle this. Let's have a meeting about it and figure out how. I have a pretty good idea.

@aDaneInSpain
Copy link
Owner Author

I have created a blog post outlining our thoughts on how to solve this. Feedback encouraged. https://www.component-creator.com/en/blog/92-component-creator-event-triggers-proposed-solution

@helpwise
Copy link

helpwise commented Dec 3, 2021

I applaud this idea. It will make CC much more fundamentally structually sound to an ongoing and update-able component solution in Joomla.

To get around this issue to date, we use CC as the table and data structure and raw data creator/editor, and then build modules around that data that allow us to custom build the interface and interaction often using override templates on the modules.

It would obviously be better to be

  1. able to customise the Components views properly, and

  2. to be able to add plugins that run before or after events for data integration and pre-save adjustment purposes.

  3. could just be a simple override system that allows mods to classes/functions and view code with the option to remove the override and go back to the base code as currently supplied

  4. Just create the triggers as you are suggesting. Although it seems a bit simplistic to do it on the tables and not the functions, but to be honest I cant think of instances I would have had difficulty implementing custom elements via table triggers.

Component Creator is a fantastic piece of tech and it makes life much easier. If you can make it customizable as above and in this thread it will be great.

I have to say I am still mainly using J3. J4 is too new and too ugly at this point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants