ssossossossosso

Forums

Covering OroCRM topics, including community updates and company announcements.  Subscribe

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 12 months ago.

  • Creator
    Topic
  • #22043

    southside
    Participant

    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.

Viewing 12 replies - 1 through 12 (of 12 total)
  • Author
    Replies
  • #22044

    Yevhen Shyshkin
    Participant

    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.html

    Our 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).

    #22045

    Yevhen Shyshkin
    Participant

    Also 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.

    #22046

    southside
    Participant

    Yevhen;

    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?

    #22047

    Yevhen Shyshkin
    Participant

    > 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.

    #22048

    southside
    Participant

    Yevhen;

    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.

    #22049

    southside
    Participant

    Yevhen;

    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.

    #22050

    Yevhen Shyshkin
    Participant

    There 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:

    – 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.

    #22051

    Igor Klipach
    Participant

    I 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.

    #22052

    Alexandr Smaga
    Participant

    Hello 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

    #22053

    David Lukac
    Participant

    I’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://www.orocrm.com/forums/topic/how-to-programatically-add-fields. I’ll appreciate any help.

    #22054

    smhr
    Participant

    It will be improved in near feature, also simple UI for grid configuration exists in our roadmap

    Any news on this?

    #22055

    prganvani
    Participant

    i 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

Viewing 12 replies - 1 through 12 (of 12 total)

You must be logged in to reply to this topic.