Can the "jcr:language" property be configured automatically on page creation? - aem

How is the jcr:language property is being configured in the below site structure, for example, on the node (/content/myapp/uk/en/jcr:content)?
{
"content": {
"myapp": {
"jcr:content" {
"us": {
"jcr:mixinTypes": "rep:AccessControllable",
"jcr:primaryType": "cq:Page"
},
"de": {
"jcr:mixinTypes": "rep:AccessControllable",
"jcr:primaryType": "cq:Page"
},
"fr": {
"jcr:mixinTypes": "rep:AccessControllable",
"jcr:primaryType": "cq:Page"
},
"uk": {
"jcr:mixinTypes": "rep:AccessControllable",
"jcr:primaryType": "cq:Page",
"jcr:content": {},
"en": {
"jcr:content": {},
}
}
}
}
}
}
This question is related to Invalid iso code stored in /content/myapp/uk/en: en_uk. I can remove the warnings mentioned in that question by changing the jcr:language value to en_GB manually in the page, the warnings are gone.
But I want to configure it in such a way that the correct jcr:language property should be automatically set to en_GB, while creating the language node itself (i.e en). Is this possible?

#raju muddana i would like to know your use case for automatically creating the jcr:language property.
Generally this language property is left over to content authors after your project implementation. in AEM any number of pages will be created with one template wich can be used for multi languages content authoring. Generally we can segregate this with content structures like an example shown in geometrix demo site (example: /content/geometrixx/en, /content/geometrixx/fr, etc.). once the content structure has been established content-authors can set this language property accordingly.
In addition to #i.net answer, just showing you that on any page in AEM by default you can add the language by using Page Properties Advanced Tab Language property. until unless if you don't customize your page properties.
Classic UI:
Touch UI:
Jcr:language Property

You can set the jcr:language to en_GB on /content/myapp/jcr:content/uk/jcr:content node. This will ensure that any pages below this node that don't have the jcr:language defined will pick this property from the parent node.

Related

Sample code for KeystoneJS 5 custom fields?

I'm interested in writing custom fields for KeystoneJS 5. The documentation is here, but I find it somewhat opaque (i.e., not fully explicatory). Is there sample code available? I looked in 'demo projects' and 'test projects' in the Keystone repo, but didn't see anything.
KeystoneJs custom fields are poorly documented and not easily accessible. in fact the whole concept of writing the whole custom field may be overkill.
here is the example one core team member has put copied form the test-project. - https://github.com/MadeByMike/keystone-custom-field/blob/7caf0139c189eadda1884a86073c6945bdd6ff05/index.js#L15
this is what you need to do:
1. you need to create a folder for the field
2. you can copy the Text field implementation to start with
3. there index.js file must export specific object (default export) like this ( I have added some comment for each line)
{
type: 'Stars', // name of the implementation
implementation: Stars, // implementation itself
views: { // all views are required you can copy the implementation from Text field)
Controller: Integer.views.Controller, // it is using controller from Integer field type
Field: require.resolve('./views/Field'), // field which goes into edit page or create dialog
Filter: Integer.views.Filter, // this adds filters in the list page
Cell: require.resolve('./views/Cell'), // view for list page where you usually see the text, for Relationship it is rendered as link.
},
adapters: {
mongoose: MongoIntegerInterface, // mongoose adapter specific inplementation
knex: KnexIntegerInterface, // knex adapter specific implementation,.
},
}
create views for each type (Field, Filter, Cell etc.)
import the field (default import) in the schema definition and use it like regular field. any custom option is passed on to the custom implementation.

Not able to navigate from one view to other

I am trying to navigate from one view to another in UI5 application but I am not able to do so. I recently created a copy of an existing view A and renamed it to B. Then I copied the controller of A and renamed it as controller of B. I now want to navigate from A to B view. I have declared the view B in routes just like A (renamed wherever necessary) but I am still not able to navigate. When I click on button in view A, I want to display B. But nothing happens. Console shows no error either. What can be the issue?
In Controller of A:
buttonClick: function(event) {
vc.getOwnerComponent().getRouter().navTo("stockDetails", {
"companyId": vc.companyId,
"stockroomId": vc.stockroomId,
"order": vc.orderNo
}, false);
},
In manifest.json:
Under routes:
{
"name": "stockDetails",
"pattern": "company/{companyId}/stockrooms/{stockroomId}/order/{order}",
"titleTarget": "",
"greedy": false,
"target": [
"menu",
"stockDetails"
]
}
Under targets:
"stockDetails": {
"viewType": "XML",
"transition": "slide",
"clearAggregation": true,
"viewName": "stockroom.stockDetails", //stockDetails View B
"viewLevel": 2,
"controlAggregation": "pages",
"controlId": "app"
}
Here are some possible causes..
Multiple Targets for <App>
It looks like you're trying to assign multiple targets ("menu", "stockDetails") to the same aggregation ("pages") at the same time. Unless it's using master-detail layout or a parent target is involved, try to assign only the right target for the right aggregation. In case of sap.m.App:
{
"name": "stockDetails",
"pattern": "...",
"target": "stockDetails"
}
Otherwise, you'll encounter unexpected behaviors depending on the implementation of the routerClass module.
Identical Patterns
Although the route name may be different ("stockDetails"), you probably have kept the route pattern when copy-pasting from the source route (A).
If it's true, you'll need to provide a distinct pattern for the route "stockDetails" as well. When identical patterns exist, the first route is always taken into account over the others.*
The sequence of the routes in the routes definition is important. As soon as a pattern is matched, the following patterns are ignored.[src]
Here, you can try to define two identical patterns and set the hash accordingly. You'll see that only the first pattern is matched which would be, in your case, the view A.
* Unless the property greedy is active in one of the other routes.
Not sure if you are using the right event for button click.
Can you try using the "press" event, and not the "buttonClick" event?
Before that, try putting a "console.log("Event Firing OK") within your buttonClick event handler, and check the console if the message is coming up. If not, you know the event is not even getting fired, and hence, your navigation code is never executed.
REFERNCE : https://sapui5.hana.ondemand.com/#/api/sap.m.Button/events/press
Best Regards,
Gopal Nair.

How to dynamically change dialog with select field

I'm new to Magnolia, and I'm making my own module.
I have a dialog box when adding a component and I want to change next fields below dynamically using a select field.
Example:
Select field with {"type 1", "type 2", ...}
IF "type 1" is selected
->show a text field below
ELSE
->show a basicUpload field below
Thanks in advance.
I believe same was already discussed here and few other places if you look over questions tagged "magnolia".
Long story short, fields are atomic, independent entities. They do not know about each other. So the only way to create such dynamic connection is over "parent" form. You need to extend form presenter and field factory (if you want select that would be SelectFieldFactory) and in there, when field is created, attach value changed or similar listener to it so when value is changed in the field, you can inform presenter to make some other field visible or hide it.
IIRC you can see example of that done in External Forms module (if you have access to enterprise code). Not sure if any of the community modules show the same.

Schema.org: How to use isAccessoryOrSparePartFor in JSON-LD?

I'm trying to declare products in JSON-LD for schema.org. I came across isAccessoryOrSparePartFor. So what do I put inside this tag? Schema.org says it should be a Product - but do I really have to put full product-declarations in it? Could I put URLs or EANs of the sparepart-products in it?
For the isAccessoryOrSparePartFor property, a Product value is expected, but not required.
From the Schema.org documentation:
Expected types vs text. When browsing the schema.org types, you will notice that many properties have "expected types". This means that the value of the property can itself be an embedded item (see section 1d: embedded items). But this is not a requirement—it's fine to include just regular text or a URL. […]
Of course, some consumers might not support other values than the expected ones.
You can use a minimal product declaration with only #context, #type and the product URL as id.
Example:
isAccessoryOrSparePartFor: [
{
'#context': 'http://schema.org',
'#type': 'Product',
id: UNIQUE_PRODUCT_ID_1'
},
{
'#context': 'http://schema.org',
'#type': 'Product',
id: UNIQUE_PRODUCT_ID_2'
},
...
]
You can check use Google's testing tool for structured data to validate.

SAPUI5: how to make select field read-only

I made a combobox using sap.m library:
var oSelection = new sap.m.ComboBox({
name: <name>,
id: <id>,
items: {
<items here>
})
},
});
Now, how do I make this field kind of read only, so when I tap it on mobile, it wouldn't bring up the mobile's keyboard, but it would bring up the selection options?
I've tried to use editable: false, but it disables the selection together with keyboard.
Thank you.
From what I could find out there's no method that allows such behaviour.
One option, that I personally would not advice, is to access the HTML DOM and disable the input field that composes the sap.m.Combobox component.
Keep in mind that if the development SAPUI5 changes the inner workings of the Combobox component your code could be broken if you update the SAPUI5 libraries.
This being said, to use this option you could do something like:
oSelection.onAfterRendering = function() {
if (sap.m.ComboBox.prototype.onAfterRendering) {
sap.m.ComboBox.prototype.onAfterRendering.apply(this);
}
document.getElementById("<id>-inner").disabled=true;
}
replace the < id>-inner by the correct id given to your component.
This was tested using version 1.22.8 of SAPUI5 development toolkit.
Use sap.m.Select instead of sap.m.ComboBox.
Select does not provide the ability to edit the field content.
In many instances the Select control can directly replace a ComboBox without any other changes to the properties or the items aggregation!