I'm using Kentico 9 and I'd like to be able to use different CK Editor style sets on different pages. I have added a style set to the styles.js file as follows.
CKEDITOR.stylesSet.add("mystyles", [{ name: "testone", element: "p" }]);
Then in the page I've added some JS as per the CK Editor web site.
if (CKEDITOR.currentInstance) {
CKEDITOR.currentInstance.config.stylesSet = "mystyles";
}
When I load the page containing the CK Editor, the style drop down contains the default style set, not the custom one I defined.
Does anyone know how to achieve this?
If I remember it right you need to define your new toolbarset in config.js (CMSAdminControls/CKEditor/config.js) dropdown.
Something like:
config.toolbar_Basic = [
['Bold', 'Italic', '-', 'NumberedList', 'BulletedList', '-', 'InsertLink', 'Unlink']
];
The other thing - you need to add new option to this dropdown in Webparts application > EditableText webpart> Properties > HTMLAreaToolbar > DataSource
Here's the documentation you need to read.
The dropdown styles are defined in CMS\CMSAdminControls\CKeditor\styles.js, such as:
{ name: 'Italic Title', element: 'h2', styles: { 'font-style': 'italic' } },
You define the name of the style (the name appears in the dropdown), and then the element and style(s) that should be applied.
After editing the file, make sure you clear your browser cache.
As most Kentico admin interface pages are nested and iframe'd, the caching is pretty agressive, and your styles might not appear until cache is cleared.
Well, it's just javascript after all, so you can simply check the url in some if statement or in some switch-case and then apply styles you need. Do you need some code example? You should be able to find many of them on the internet :)
Here is how I solved my issue. I added the following to styles.js:
CKEDITOR.stylesSet.add("my-styles", [
{ name: "Paragraph", element: "p" },
{ name: "Heading 1", element: "h1" }
]);
Then, in the master page for the area of my site that needs to use the "my-styles" style set, I added:
<script>window.ckstyleset = "my-styles"</script>
Finally, in config.js I added:
var styleset = window.ckstyleset ? window.ckstyleset : "default";
config.stylesSet = styleset;
Using this approach I was able to customise the styles listed in the drop down depending on what master page was is use.
Related
I'm trying to setup a custom screen in the mobile app, and there are a few things that are still a mystery.
One of them is how to get a PXTextEdit field to show multiple lines, or even allow entry into that field without it just highlighting the field and no way to add to it.
The other is how to add a Rich Text control to the mobile app ala the Cases screen. I've tried using the code to add it the way the Cases screen does. I have a PXRichTextEdit field, called 'Details', but this doesn't show up on the mobile app at all:
add field "Details" {
textType = HTML
}
In this context:
add screen AC503000 {
add container "MeetingAgenda" {
add field "MeetingID"
add field "Subject"
add field "Status"
add field "MeetingDate"
add field "MeetingTime"
add field "Details" {
textType = HTML
}
add recordAction "Save" {
behavior = Save
}
add recordAction "Cancel" {
behavior = Cancel
}
add recordAction "Delete" {
behavior = Delete
}
}
I've also tried to add a container called "Details" since this shows up in the WSDL file, and that shows a menu item, but takes you nowhere, and sends the app into a tailspin where it can't recover and has to be restarted.
At this point I'm lost as to how to do these two things...
To enable multiline mode, use
add field "Details" { textType = PlainMultiLine }
To show your PXRichTextEdit field try to use {Container Name}#{Field Name} from the WSDL
add field "Details#Details" { textType = HTML }
I would like to permanently set the default view in OpenCart 2.1.0.2 to list-view instead of grid-view. I do not want to give my visitors ability to switch to grid-view; hence I'd like to completely disable grid-view and keep only list-view. Any assistance would be greatly appreciated.
You can do that using two methods for default list view.
1st method: replace following code (catalog/view/javascript/common.js)
if (localStorage.getItem('display') == 'list') {
$('#list-view').trigger('click');
} else {
$('#grid-view').trigger('click');
}
and using the following code in place
if (localStorage.getItem('display') == 'grid') {
$('#grid-view').trigger('click');
} else {
$('#list-view').trigger('click');
}
2nd method: If you don't want/like to permanently remove grid view then remove the code in (catalog/view/javascript/common.js) and make following code in common.js only
$('#grid-view').trigger('click');
We have a custom action that follows some custom workflow logic behind the scenes and want to add a layout to the data captured to the settings. I was able to add a checkbox to enable the layout (its an optional thing) associated with the custom action but I cant seem to find how to add a layout editor to our form?
var f = shapeFactory.Form(
Id: "ActionForm",
_Outcomes: shapeFactory.TextBox(Id: "action-text-box", Name: "Action", Title: T("Action")),
_HasLayout: shapeFactory.CheckBox(Id: "HasLayout", Name: "HasLayout", Title: T("Uses Layout"), Value: "true"),
//_Layout: shapeFactory.Parts_Layout_Edit(Id: "Layout", Name: "Layout", Title: T("Layout"))
);
This is where I am at at the moment (the last line is commented because the part name is incorrect), but I feel I am missing some core concept for adding the layout editor... Any help would be appreciated!
I figured this out after much experimentation.
Add to the form description
_Form: shapeFactory.EditorTemplate(Id: "Form", Name: "Form", Title: T("From"), TemplateName: "Parts.Layout", Prefix: "LayoutPart",
Model: new LayoutPartViewModel {
LayoutEditor = layoutEditorFactory.Create("", Guid.NewGuid().ToString())
})
and then you need to add a script to the form page in order to reload the layout editor with the bound data.
$(document).ready(function(){
var layoutEditorData = JSON.parse($("[name$='.LayoutEditor.Data']").val());
window.layoutEditor = new LayoutEditor.Editor(window.layoutEditor.config, layoutEditorData);
});
I'd like to add some custom facets to the Alfresco (version 5.0.a) search page. I've created an extension which allows to override already created facets:
<import resource="classpath:/alfresco/site-webscripts/org/alfresco/share/imports/share-header.lib.js">
<import resource="classpath:/alfresco/site-webscripts/org/alfresco/share/imports/share-footer.lib.js">
var facet = widgetUtils.findObject(model.jsonModel, "id", "FCTSRCH_FACET_DESCRIPTION");
facet.config.label = "Document type";
facet.config.facetQName = "{http://www.someComp.com/model/comp/1.0}personGroup";
But it is not the right way I think.
The problem is that I cannot override the parent widgets, since they don't have ids (faceted-search.get.js).
How do I manage to add a custom facet to the model?
Another question is regarding parameter of the facet with name facetQName. In the same file (faceted-search.get.js) I met some strange syntax which I don't understand.
Some examples:
facetQName: "{http://www.alfresco.org/model/content/1.0}creator.__.u",
facetQName: "{http://www.alfresco.org/model/content/1.0}modifier.__.u",
facetQName: "{http://www.alfresco.org/model/content/1.0}description.__",
What do these .__.u and .__ suffixxes mean?
Well I finally solve the problem.
Just for clarification: I had a requirement to use 5.0.a version in which there is no Search Manager page.
The solution which I used is a bit dirty, but it worked. I just overwrite the faceted-search.get.js and changed the facets array by adding my custom metadata:
// Compose the individual facets
var facets = [
...
{
id: "FCTSRCH_FACET_DOCUMENT_TYPE",
name: "alfresco/search/FacetFilters",
config: {
label: "Document Type",
facetQName: "{http://www.mycomp.com/model/efiles/1.0}typeName.__.u",
sortBy: "ALPHABETICALLY",
hitThreshold: 1,
minFilterValueLength: 5,
maxFilters: 10,
useHash: false
}
...
If you are interested in details you can check this post: http://streetturtle.github.io/2015/01/20/faceted-search-alf-5-0-a/
The current project I'm on is utilizing tenant sites. With each site, we want the ability to change the logo through out the tenant site by modifying the its settings (on the admin page, settings > general).
I've added two text fields to the site settings by following this well documented tutorial. However, I'd like the user to be able to pick the logos using the media picker instead of typing in the path.
Currently I have a LogoBarSettings part with its record, driver and handler. I'm not sure how to add the media picker to the my LogoBarSettings and even if I did, must I also create another handler, driver, and record for it? I can't imagine I would but I'm pretty stuck at this point.
Can someone provide some direction on this?
Here is my LogoBarSettings
public class LogoBarSettings : ContentPart<LogoBarSettingsPartRecord>
{
public string ImageUrl
{
get { return Record.ImageUrl; }
set { Record.ImageUrl = value; }
}
public string ImageAltText
{
get { return Record.ImageAltText; }
set { Record.ImageAltText = value; }
}
}
The MediaPicker is invoked through Javascript, so you shouldn't need to change any of your model classes. When the MediaPicker is loaded for a page, it sets up a jQuery event handler for all form elements on the page. Triggering the event orchard-admin-pickimage-open will open the MediaPicker. Supply a callback function to capture the picked media.
Here is a quick example that you can run in Firebug or Chrome Developer Tools from a page which has the MediaPicker loaded, such as a Page editor:
$('form').trigger("orchard-admin-pickimage-open", {
callback: function(data) {
console.log(data);
}})
This should print something similar to this:
Object {img: Object}
img: Object
align: ""
alt: ""
class: ""
height: "64"
html: "<img src="/Media/Default/images/test.jpg" alt="" width="64" height="64"/>"
src: "/Media/Default/images/test.jpg"
style: ""
width: "64"
__proto__: Object
__proto__: Object
The BodyPart editor integrates Orchard's MediaPicker with TinyMce, so you can start looking at that module for a more complete example, specifically Modules\TinyMce\Scripts\plugins\mediapicker\editor_plugin_src.js.