use tablename different than slug - bolt-cms

I am buliding a single-language website (german) but like to have my code/tables etc. in english.
When I define a contenttype like so:
plays:
name: Theaterstücke
slug: theaterstuecke
tablename: plays
singular_name: Theaterstück
singular_slug: theaterstueck
bolt uses the table bolt_plays but in twig I have to use ....records = "theaterstueck/latest/6". But I would like to have the template use english routes ("play/latest/6") and the URL still http://example.com/theaterstuecke
Do I have to use translations and routing or is there an easier way?

Change both slugs to :
plays:
name: Theaterstücke
slug: plays
tablename: plays
singular_name: Theaterstück
singular_slug: play
And it should be fine

Related

Is it possible to model a json with class?

Short question: is it possible to model a json with a class in TS (/angular) ?
Example:
I'm using Firebase and I have a node /books which looks like:
books
-- 157sq561sqs1
-- author: 'Foo'
-- title: 'Hello world'
(157sq561sqs1 here is the id of the book)
it will looks:
157sq561sqs1 : { author: 'Foo', title:'Hello world'}
I tried to model that with:
export class Book {
id: number;
author: string;
title: string;
}
But it will looks like:
books
-- 0
-- id: 157sq561sqs1
-- author: 'Foo'
-- title: 'Hello world'
Is it possible to model something like that in order to have the model shown ?
I think it is not possible directly with typescript.You have to write code for that.

How to change the field delete instead of id in loopback?

I want to the delete a few rows in MySQL table using loopabck. But I don't want to use the id to delete the record. I'm trying it in Angular SDK. My code is:
ModelName.destroyById({ fieldName : myValue })
.$promise
.then(function() {
});
I'd be very thankful for ideas.
Seems like you need to use the destroyAll method, which does what you want, but you need to set up remoting for it first, since it's disabled by default:
ModelName.remoteMethod('destroyAll', {
isStatic: true,
description: 'Delete all matching records',
accessType: 'WRITE',
accepts: {arg: 'where', type: 'object', description: 'filter.where object'},
http: {verb: 'del', path: '/'}
});
Then after that you regenerate your Angular client and you can use it like this in the client side:
ModelName.destroyAll({ filter: { fieldName : myValue }}).$promise.then(...)
Note that using destroyAll is risky as if you have any mistakes in your code you will end up losing data. Enabling it to client side might be security concern.
Another way to do this is to write your own remote method which uses destroyAll in turn with proper validation of the inputs.

Inputfield for link to any contenttype in Bolt-cms

is it possible to setup a field which links to a specific content of multiple content types?
So assuming there are 3 predefined contenttype CA, CB, CC. I would like to setup an input field, which allows to link to any content of the contenttypes CA, CB, CC.
Does anybody know how to do this or what section of bolt needs to be extended?
Thanks a lot!
I found the following three ways to link to other pages but they are always a link to one contenttype only.
By selectentry
selectentry:
type: select
values: entries/id
postfix: "Select an entry"
autocomplete: true
sort: title
Single relation
relations:
entries:
multiple: false
label: "Choose an entry"
order: -id
format: "{{ item.title|escape }} <span>(№ {{ item.id }})</span>"
postfix: "By selecting an Entry, you're creating a bi-directional relationship to that Entry."
Multiple relations
relations:
pages:
multiple: true
order: title
label: Select zero or more pages
this is currently not possible to do in a clean way. You could add a few type: select fields, and then in your template use {% if %} statements to display the right thing.

Association example is not executing

I'am trying to execute the Association example present in Data binding of Kitchensink example
(http://dev.sencha.com/ext/5.0.1/examples/kitchensink/#binding-associations) in Extjs5. It works fine for me (In my app am using the Json file for my Data part).
Now am trying to move the Customer and Order model to app/model/test/Customer.js and app/model/test/Order.js and modified my dependenciew accordingly.
My Customer Grid is loading fine for me, but on clicking of record Order gris not getting loaded into memeory.
Here am pasting my Sample code for Orders.js file for refrence
Ext.define('myApp.model.test.Order', {
extend: 'myApp.model.Base',
fields: [
{ name: 'date', type: 'date', dateFormat: 'Y-m-d' },
'shipped',
{
name: 'customer',
reference: {
parent: 'test.Customer'
}
}
]
});
In the above file i tried with name: 'customerId' as well but no result :(
Did any body got the same problem? Any help on this is highly appreciated.
Thanks in Advance
Make sure you use a requires config somewhere to be absolutely sure your model classes are all loading. Also check the docs for the reference config:
http://ext5-docs.site/#!/api/Ext.data.field.Field-cfg-reference
Looks like you might want to just try:
{ name: 'customerId', reference: 'myApp.model.test.Customer' }

Ember Data findAll() not populating models?

new to ember js, and working on an app using ember-data. If I test with same data using FixtureAdapter, everything populates in the html template ok. When I switch to RESTAdapter, the data looks like it's coming back ok, but the models are not being populated in the template? Any ideas? Here's the code:
App.Store = DS.Store.extend({
revision:12,
//adapter: 'DS.FixtureAdapter'
adapter: DS.RESTAdapter.extend({
url:'http://bbx-dev.footballamerica.com/builderapirequest/bat'
})
});
App.Brand = DS.Model.extend({
name: DS.attr('string'),
numStyles: DS.attr('string'),
vendorId: DS.attr('string')
});
App.BrandsRoute = Ember.Route.extend({
setupController:function(controller){
},
model:function(){
return App.Brand.find();
}
});
And here is the data coming back, but not being inserted into the template!
returnValue: [{numStyles:1, name:Easton, vendorId:6043}, {numStyles:1, name:Louisville Slugger, vendorId:6075},…]
0: {numStyles:1, name:Easton, vendorId:6043}
1: {numStyles:1, name:Louisville Slugger, vendorId:6075}
2: {numStyles:1, name:Rawlings, vendorId:6109}
3: {numStyles:7, name:BWP Bats , vendorId:6496}
4: {numStyles:1, name:DeMarini, vendorId:W002}
status: "ok"
And here is the template:
{{#each brand in model.returnValue }}
<div class="brand-node"{{action select brand}}>
<h2>{{brand.name}}</h2>
<p>{{brand.numStyles}} Styles</p>
</div>
{{/each}}
Any help would be greatly appreciated! I'm not getting any errors, and the data seems to be coming back ok, just not getting into the template. Not sure if the returned dataset needs "id" param?
I am also using the Store congfig to alter the find() from plural to singular:
DS.RESTAdapter.configure("plurals", {
brand: "brand"
});
The way the API was written, its expecting "brand" and not "brands"... maybe its something to do with this??
Thanks in advance.
You have stated:
Not sure if the returned dataset needs "id" param?
Yes you are guessing right, you data coming back from the backend need's an id field set. And if the id field name is different then id you should also define this in ember like so:
App.Store = DS.Store.extend({
revision:12,
//adapter: 'DS.FixtureAdapter'
adapter: DS.RESTAdapter.extend({
url:'http://bbx-dev.footballamerica.com/builderapirequest/bat'
}),
serializer: DS.RESTSerializer.extend({
primaryKey: function (type) {
return '_my_super_custom_ID'; // Only needed if your id field name is different than 'id'
}
})
});
I suppose your Fixtures have an id defined thus it works, right?
Note: you don't need to define the id field at all explicitly, ember add's automatically the id field to a model, so your model is correct.
Here a website that is still a WIP but can be good reference for this conventions
and as stated there:
The document MUST contain an id key.
And this is how your JSON should look like for a collection of records:
{
"brands": [{
"id": "1",
"numStyles": "1",
"name": "Easton",
"vendorId" :"6043"
}, {
"id": "2",
"numStyles": "4",
"name": "Siemens",
"vendorId": "6123"
}/** and so on**/]
}
Note: as you have shown you JSON root is called returnValue this should be called brand or brands if you are not adapting the plurals. See here for reference for the JSON root I'm talking about.
Hope it helps