Forums › Forums › OroCRM › OroCRM – Programming Questions › Simple example of how to make a change to OROCRM?
This topic contains 12 replies, has 7 voices, and was last updated by prganvani 7 years, 3 months ago.
Starting from March 1, 2020 the forum has been switched to the read-only mode. Please head to StackOverflow for support.
- CreatorTopic
- December 14, 2013 at 1:03 pm #24661
Forum;
Can anyone supply a simple guide to the file structure.
I cannot fathom how the system is constructed and cannot see how to make a simple change.
Lets say I want to hide a field on the new contact form example the TWITTER field if I did not want to show that how can I hide.
Alternatively if I wanted to change the TITLE “New Contact” to “New Client” how is that done.
The system looks great but it looks impossible to make simple changes.
Maybe a guide or some examples would make it all much clearer.
I hope someone can help.
- CreatorTopic
- AuthorReplies
- December 16, 2013 at 4:13 am #24662
Hello, southside
> Lets say I want to hide a field on the new contact form example the TWITTER field if I did not want to show that how can I hide.
Twitter is a static field, so to hide it you should to override template OroCRM/Bundle/ContactBundle/Resources/views/Contact/update.html.twig and put it to app/Resources directory (see http://symfony.com/doc/current/book/templating.html#overriding-bundle-templates).
In case of dynamic fields you can simply hide it in entity configuration.> Alternatively if I wanted to change the TITLE “New Contact” to “New Client” how is that done.
You should override view page template OroCRM/Bundle/ContactBundle/Resources/views/Contact/view.html.twig in the same way.
> The system looks great but it looks impossible to make simple changes.
OroCRM as a Symfony application can be extended in the same way – you can start from Symfony Book and Cookbook:
– http://symfony.com/doc/current/book/index.html
– http://symfony.com/doc/current/cookbook/index.htmlOur API for components is not stable yet, so some things can be changed, but we are going to create articles about creating and customization in the nearest future (most probably right after stable release version).
December 16, 2013 at 4:19 am #24663Also there is even easier way to do what you want – you can extend OroCRMContactBundle and do all required changes there. Documentation – http://symfony.com/doc/current/cookbook/bundles/inheritance.html.
December 18, 2013 at 2:15 am #24664Yevhen;
Many thanks when do you think you will have a stable release we could use for a client project?
Also I see regards the over-rides I do a lot of Joomla development and it uses the template over-ride idea which is great for making core changes without breaking upgrade ability.
I will give this a try.
Do you have to rebuild any schema after making changes?
December 18, 2013 at 2:26 am #24665> Do you have to rebuild any schema after making changes?
Only if you made some changes in entity structure (f.e. add new fields, or update types of existing ones). Regular update can be done using doctrine:schema:update command, update of extended fields should be done from UI from Extended Entity management page.December 18, 2013 at 2:49 am #24666Yevhen;
Okay to check as this is part of what is confusing as a beginner.
The folder structure.
Do you mean I take the following file:
/crm-application/vendor/oro/crm/src/OroCRM/Bundle/ContactBundle/Resources/views/Contact/update.html.twig
Make changes to the file and place it in:
/crm-application/app/Resources/update.html.twig
Or does it need to be in one of the subfolders of this directory or do I need to create a new subfolder for the override maybe called “Contact” and place it in the views folder?
In /crm-application/app/Resources/ I have the following folders:
java, translations, TwigBundle, views.
I hope you can help and again after I copy the file do I need to rebuild a cache or anything for it to take effect.
December 18, 2013 at 4:04 am #24667Yevhen;
Got it sorted.
I did the following for anyone else who wants to know.
I create a folder OroCRMContactBundle and inside that a folder views and inside that a folder Contact and placed update.html.twig inside that to give the following path.
/crm-application/app/Resources/OroCRMContactBundle/views/Contact/update.html.twig
I then rebuilt the cache like this as sudo root in my case.
cd to directory crm-application on the server then run
php app/console cache:clear –env=prod –no-warmup
The changes then took effect.
December 18, 2013 at 4:28 am #24668There are two ways of extending:
1) extending in app/Resources, should be used for specific installation (http://symfony.com/doc/current/book/templating.html#overriding-bundle-templates);
So, to customzie OroCRM/Bundle/ContactBundle/Resources/views/Contact/update.html.twig, you have to copy this template to app/Resources/OroCRMContactBundle/views/Contact/update.html.twig
and do all required fixes there.2) inheritance of the bundle, should be used if you want to do it flexible and, f.e., reuse it somewhere else (http://symfony.com/doc/current/cookbook/bundles/inheritance.html)
To customzie OroCRM/Bundle/ContactBundle/Resources/views/Contact/update.html.twig, you have to:
– create new bundle (let it be src/MyBundles/MyContactBundle)
– inherit it from OroCRMContactBundle (see the manual)
– create file src/MyBundles/MyContactBundle/Resources/config/oro/bundles.yml to register new bundle:1234bundles:- MyBundles\MyContactBundle\MyBundlesMyContactBundle– copy OroCRM/Bundle/ContactBundle/Resources/views/Contact/update.html.twig to src/MyBundles/MyContactBundle/Resources/views/Contact/update.html.twig and do all required fixes there
Second way is better because it is more flexible and not affects root application. And don’t forget to execute clear:cache after template modification to apply new templates.
January 14, 2014 at 6:32 am #24669I tried to override datagrid.yml from OroCRM\Bundle\ContactBundle to remove some columns in contacts datagrid. I just followed instructions above but get and error “Datagrid source “Array” does not exist” what i did wrong? datagrid.yml in my bundle is just a copy or original file i didn’t any changes.
January 15, 2014 at 5:07 am #24670Hello Igor.
Right now datagrid configuration could not be overridden in such way. You may create listener that will remove columns from configuration before datagrid build. It will be improved in near feature, also simple UI for grid configuration exists in our roadmap
January 29, 2014 at 9:18 am #24671I’d like to go further from overriding Twig templates – e.g. adding fields to entities programatically, so I’ve set up a separate topic for it: http://oroinc.com/orocrm/forums/topic/how-to-programatically-add-fields. I’ll appreciate any help.
February 17, 2015 at 3:35 am #24672It will be improved in near feature, also simple UI for grid configuration exists in our roadmap
Any news on this?
December 15, 2016 at 10:41 pm #24673i got an error when i use second option:
inheritance of the bundle, should be used if you want to do it flexible …..
Error:
PHP Fatal error: Class ‘MyBundles\MyContactBundle\MyBundlesMyContactBundle’ not found in D:\xampp\htdocs\orocrm10\app\cache\de_\bundles.php on line 48
Fatal error: Class ‘MyBundles\MyContactBundle\MyBundlesMyContactBundle’ not found in D:\xampp\htdocs\orocrm10\app\cache\de_\bundles.php on line 48
- AuthorReplies
The forum ‘OroCRM – Programming Questions’ is closed to new topics and replies.