Announcement

Collapse
No announcement yet.

Custom listview : link to external content.

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Custom listview : link to external content.

    I use Geonames as a way to link multiple locations to an account.

    For this I use an INT field that holds the Geoname ID.

    When in list mode I want to be able to link the ID it to the geonames website : http://geonames.org/83643

    So I added a custom view to the /Custom/Resources/layouts/myentity/list.json :

    Code:
            {"name":"geonameid",
            "view": "views/fields/geoname"
            },
    and created a view based on URL fieldtype: client/src/views/fields/geoname.js

    Code:
    Espo.define('Views.Fields.Geoname', 'Views.Fields.Base', function (Dep) {
    
        return Dep.extend({
    
            type: 'url',
    
            listTemplate: 'fields.url.list',
    
            detailTemplate: 'fields.url.detail',
    
            setup: function () {
                Dep.prototype.setup.call(this);
                this.params.trim = false;
            },
    
            data: function () {
                return _.extend({
                    url: this.getUrl()
                }, Dep.prototype.data.call(this));
            },
    
            getUrl: function () {
                var url = this.model.get(this.name);
                url= "http://geonames.org/"+url;
                return url;
            }
    
        });
    });
    Two questions :
    • I would rather move this to a custom area, and not put that directly in /client/. What is the preferred file location for custom views to stay upgrade safe?
    • suggestion : a general wrapper would be better , eg a field type "customlink" with an option to provide a minitemplate in the fielddefinition : for example,if you have an product ID from a third party and want to have direct access, you could provide this minitemplate
      Code:
      <a href="http://myproductprovidersite/itemdescription/nr/{{field}}"> {{field}} </a>






  • #2
    Create a folder called custom in client directory. Then in the json file, change view to, "Custom:Fields.GeoName". Then in js file, Espo.define("Custom:Views.Fields.GeoName", dependency file,function(Dep). If you don't want to put in the client directory, then you have further investigate how to point view to correct directory.

    Comment


    • #3
      Thank you, ill try that

      Comment

      Working...
      X