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 :
and created a view based on URL fieldtype: client/src/views/fields/geoname.js
Two questions :
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"
},
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;
}
});
});
- 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>

Comment