× Please submit new Bug Reports on GitHub: github.com/Jensen-Technologies/component-creator-issues/issues


2 years 1 week ago #9921 by infoal
HOW TO CUSTOMIZE CODE was created by infoal
Hi, i love component creator, but it's hard to make code customization without to lose it in every component update.
I've read that Jensen's team have been working in triggers system to help to users like me to customize the code, but it only works in J4.

I was trying if "empty views" can be a solution for me, and it's not.... but and I think that a similar concept can be a perfect solutions with a little bit of hacking.

What i do is:

- Create the table, fields and views in component creator, in regular way, in this example i will call it "UserRegistration"
- Create a Empty View called "CustomizedUserRegistration"
- Compile, download, install it in my Joomla Website, and create the menu Items. The menu items should call to "CustomizedUserRegistration" views.

Then, I copy all the content of every php and xml file corresponding to "UserRegistration" to "CustomizedUserRegistration", in every component folder:
/components/com_name/controllers/userregistration.php -> customizeduserregistration.php
/components/com_name/controllers/userregistrationform.php -> customizeduserregistrationform.php
/components/com_name/controllers/userregistrations.php -> customizeduserregistrations.php
and the same in models, models/forms, and views folders...

After copy all the php and xml files content, I use a massive text replace tool (Agent Ransack) to replace all the strings inside files. Every string "UserRegistration" should be replaced by "CustomizedUserRegistration", including class names, funcion names... the only string that should NOT be replaced is the QUERY string in components/com_name/models/userregistrations.php that should continue opening the original table ($query->from('#__comname_userregistrations')).

Finally, the most important files are:
/components/com_name/router.php and /component/helpers/legacyrouter.php
Inside these 2 files, it's necessary to copy the functions and conditions inside functions to adapt it from "UserRegistration" to "CustomizedUserRegistration"

And thats all.

It can be done in 5 minutes,
- go to Component Creator
- Remove the Empty View called "CustomizedUserRegistration"
- Compile and download 2 TIMES
- Install and repeat STEP 4

Then, you component is updated, but your "CustomizedUserRegistration" views are still working without changes.

With this method, you can make changes on Component Creator, for exemple creating new tables, new views, modify table fileds, and the changes will not affect you "CustomizedUserRegistration" view... but you should repeat STEP 4 every time that you install a new update, modifyng /components/com_name/router.php and /component/helpers/legacyrouter.php files... or simply copy your old versions over the new versions. Only 2 files, all your modified files will stay safe.

I'm using this method during tha last year in 5 production websites without surprises.

Well, I have a question to Jensen's Team.
¿Can you study any way to create a new kind of view in your system to make this process easier?
I dont know, may be a new kind of view "Customized view". As "Empty view", should create the functions in router.php and legacyrouter.php, and create the folders, but without files inside. Doing this, i think that news views create or "cloned" by users, can survive to component updates.

What do you think about it?


Please Log in or Create an account to join the conversation.

2 years 1 week ago #9923 by Ryan Minnig
Replied by Ryan Minnig on topic HOW TO CUSTOMIZE CODE
I have been wondering the same thing. I'm an experienced embedded programmer for 20+ years and a moderate SQL/PHP/HTML programmer with moderate knowledge of web programming but a novice with Joomla programming. I have several components that are starting to come together from the design standpoint with the proper database tables and the simplicity of navigation that CC provides, and it has been a very good eye-opener to how powerful CC really is! Kudos!
However, I'm getting to the same point you are at where I'm wanting to have custom code, for instance joining tables for a different view, different views of the same table data, having extra custom buttons on the form etc. In some respects I have been overriding my primary template with different views for the front end, but I eventually want to put the component on the Joomla Extensions site and it seems that template overrides are not the proper way to go.
I had also looked into plugin development (perhaps the CC author with create a module and plugin tool at some point in the future?) as a way to display data differently. In many respects, my lack of knowledge of the proper Joomla way of architecting a complete web app is a hinderance, but when I study many of the freely available components on extensions.joomla.org I see many different ways of doing things and I really want to stay true to Joomla4 because I love the fresh new look and support for APIs, custom fields, Bootstrap 5 and newer versions of PHP and MySQL.
I'm sorry my reply doesn't really help you, but I wanted to share a similar experience and I will try to share my tricks when I come up with any.

Please Log in or Create an account to join the conversation.

2 years 15 hours ago #9930 by infoal
Replied by infoal on topic HOW TO CUSTOMIZE CODE
Thank you very much for your answer, I also got to know Component Creator late.
If I had known before I would have saved hundreds of hours of work.

Yes, I also use the Overrides templates, but I would like to do it the right way.
I think I understand well the process that the Component Creator website follows when generating the files that users download, and I think it would not be very complicated for Jensen's team to create a solution, something like "Fake views", or "Cloned Views" ... maybe if several users suggest it they can study it.

Please Log in or Create an account to join the conversation.

1 year 10 months ago #9949 by medienmodernisierer.de
Replied by medienmodernisierer.de on topic HOW TO CUSTOMIZE CODE
I am a switching user coming from J-Cook. Unfortunately the developer does not answer there anymore and Joomla 4 is not supported. That's why I moved over to here now.

His creator had an included fork system using a folder which contained all files that would simply replace the original ones if present. The fork folder was always empty in the generated component, so that an upgrade would not affect the custom code. To share the component you only need to add the fork folder and zip again.

For now I would use empty views and simply include a php file to make sure that one is not replaced by a download. Then you would only need a line of code to include it. Sounds easier to me than replacing and deleting from the creator.

Please Log in or Create an account to join the conversation.

1 year 10 months ago #9950 by Søren Beck Jensen
Replied by Søren Beck Jensen on topic HOW TO CUSTOMIZE CODE

Just wanted to say that we are following this thread and that we have posted a blog post about this subject back in August and are looking for input on the best way to solve this. The folder seems like it could also be a good option, but it does not follow the Joomla way, which we in general are big believers of.

Please contribute your thoughts.


Søren Beck Jensen
Founder, Component-Creator.com
The following user(s) said Thank You: Alejandro Contreras

Please Log in or Create an account to join the conversation.

1 year 4 months ago #9977 by Pete
Replied by Pete on topic HOW TO CUSTOMIZE CODE
Joomla doesn't have a way to over-ride anything but template PHP files (The View part of MVC). I use this to great effect by creating an empty list page in CC and then overriding that page with all the code I need in the template/html/... files, but it moves us a long way from the MVC system, which is worse than anything you can build in to allow full MVC override.

In short you have no choice but to roll your own custom MVC override system to get this working.

Please Log in or Create an account to join the conversation.

Time to create page: 0.178 seconds
Powered by Kunena Forum

We use cookies so that you can place orders and we can provide a better service. You can control the use of cookies at the individual browser level. If you reject cookies, you may still use our website, but your ability to use some features or areas of our website may be limited.