I've add a new address-formater. In which folder I've to upload the string and file?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ctheuring
    Senior Member
    • Oct 2022
    • 138

    I've add a new address-formater. In which folder I've to upload the string and file?

    I've expand the html/application/Espo/Resources/metadata/app/addressFormats.json with Formatter5
    and I've add Formatter5.php in html/application/Espo/Classes/AddressFormatters/
    Both changes may be overwritten in an update.
    So the question: where to upload the new version and file? The whole file or only the new part of the json-file?

    Christoph
    P.S.
    this make the address-layout useful for Germany and near by countries.
  • yuri
    Member
    • Mar 2014
    • 8453

    #2
    custom/Espo/Custom/Resources/metadata/app/addressFormats.json (include only your custom format, as custom metadata is merged with core).

    Your formatter you can put somewhere in custom/Espo/Custom/ namespace.
    Last edited by yuri; 11-02-2023, 09:30 PM.
    If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

    Comment

    • ctheuring
      Senior Member
      • Oct 2022
      • 138

      #3
      Thank you yuri,
      now I've understood the espo-system of adding custom-code

      Christoph

      Comment

      • ctheuring
        Senior Member
        • Oct 2022
        • 138

        #4
        yuri sorry - question again - because it didn't run:
        1. I've copied custom/Espo/Custom/Resources/metadata/app/addressFormats.json with content
        -----------schnipp----------
        {
        "5": {
        "formatterClassName": "Espo\\Classes\\AddressFormatters\\Formatter5"
        }
        }​
        -----------schnapp-----------
        2. I've copied formatter5.php to custom/Espo/Custom/Classes/AddressFormatters
        content of formatter5.php see attachment
        all rights the same as the examples from application/Espo/...
        rebuild
        ... but there is still NO No.5. to choose ...
        What's going wrong?

        Christoph

        Comment

        • rabii
          Active Community Member
          • Jun 2016
          • 1250

          #5
          Hey Christoph,

          You have a wrong namespace on your Formatter5.php namespace should be

          PHP Code:
          namespace Espo\Custom\Classes\AddressFormatters; 
          

          Currently you have it set as
          PHP Code:
          namespace Espo\Classes\AddressFormatters; 
          
          That is why the class is not loaded.

          Cheers​
          Rabii
          Web Dev

          Comment

          • ctheuring
            Senior Member
            • Oct 2022
            • 138

            #6
            thanks rabii ... I thought, this is the solution
            rebuild
            but still the same: no No. 5 :-(
            so I changed path also in custom/Espo/Custom/Resources/metadata/app/addressFormats.json
            rebuild
            still no No. 5 ???

            Christoph

            Comment

          • ctheuring
            Senior Member
            • Oct 2022
            • 138

            #7
            Hello,

            above/my "problem" is not a game-changer or important to "win the war" - but it is an example to learn more about espoCRM and its basic code and its functionallity.

            first 2 importend questions to custom-files:
            1. did custom-files allways MERGE with their original-counterpart or, on specific case(s), they REPLACE their original-conterpart? E.g. variable notMergeable": true
            2. the namespace in the custom-files always point to their custom-version or to their original-version?

            now (my) how to append a new AddressForm - within some questions about it:

            1. from folder application/Espo/Core/Field/Address :
            - AddressAttributeExtractor.php
            - AddressBuilder.php
            - AddressFactory.php
            save custom-versions in folder custom/Espo/Custom/Field/Address

            2. save the new Formater as Formatter5.php to custom/Espo/Custom/Classes/AddressFormatters
            the namespace point to Espo\Custom\Classes\AddressFormatters

            3. as an example from application/Espo/Resources/metadata/app/addressFormats.json
            save the expanded parts to custom/Espo/Custom/Resources/metadata/app/addressFormats.json
            the formatterClassName changed to "Espo\\Custom\\Classes\\AddressFormatters\\Formatt er5"

            4. copy and expand application/Espo/Resources/metadata/fields/address.json
            save as/in custom/Espo/Custom/Resources/metadata/fields/address.json
            content-variables are:
            "notMergeable": true, -> this meams, that I've to save the WHOLE content with the expanded parts ?
            "notCreatable": false, -> ??
            "filter": true,
            "skipOrmDefs": true,
            "personalData": true,
            "valueFactoryClassName": "Espo\\Core\\Field\\Address\\AddressFactory", -> change (or not) to "Espo\\Custom\\Field\\Address\\AddressFactory" ???
            "attributeExtractorClassName": "Espo\\Core\\Field\\Address\\AddressAttributeE xtra ctor" -> change (or not) to "Espo\\Custom\\Field\\Address\\AddressAttribut eExt ractor" ???

            5. What's about juris link to https://docs.espocrm.com/development/custom-field-type/ ??
            in this doc the aim was to delete or change an EXISTING field - my aim is to ADD NEW fields and a new AddressForm

            Are all of my points correct and nessessary?

            I'll not realize the points before I'm sure, it's correct what I want to to (it's a lot of work ... and if it's wrong, it may be damage the application)

            Christoph

            Last edited by ctheuring; 11-06-2023, 04:35 PM.

            Comment

            Working...