Neos CMS: Extending page properties for the backend - neoscms

Is it possible to have a checkbox in the Neos backend for every page to show/hide some HTML and JavaScript code in the page (and even better also for all sub pages)?

You can add anew property for Neos.Neos:Document or create a new type and then attach it as superType to every page type you want.
Sample settings for Neos.Neos:Document:
'Neos.Neos:Document':
ui:
inspector:
groups:
globalsettings:
label: 'My special settings'
tab: 'default'
properties:
yourVariableName:
type: boolean
defaultValue: false
ui:
label: 'Hide content'
reloadPageIfChanged: FALSE
inspector:
position: 10
group: 'globalsettings'

If you want to check if the current or parent page has a selected value you can do this with Fusion:
nodeOrParentNodeIsChecked = ${q(node).closest('[instanceof Neos.Neos:Document][yourVariableName]').property('yourVariableName')}
Fell free to ask on https://discuss.neos.io, because this is our official forum. You'll find more information here: https://www.neos.io/docs-and-support/support.html

Related

form framework in news detail view

I tried to implement a form with form framework in the news detail view. The basic way is explained here:
https://docs.typo3.org/c/typo3/cms-form/10.4/en-us/I/Concepts/FrontendRendering/Index.html#render-within-your-own-extbase-extension
Viewhelper:
<formvh:render persistenceIdentifier="EXT:myext/Resources/Private/Forms/myforms.form.yaml"/>
Form definition:
renderingOptions:
controllerAction: detailAction
addQueryString: true
submitButtonLabel: Absenden
fluidAdditionalAttributes:
class: ''
identifier: myForm
label: 'myLabel'
type: Form
prototypeName: myPrototype
The form is displayed. When I submit the form the news detail view is shown again including the form, but it's empty. The form is not processed. Something is missing, but I cannot find it in the manual.
Thanks!
I think the important part is written in the note below the linked paragraph:
In general, you can override each and every form definition with the help of TypoScript (see ‘TypoScript overrides’). This feature is not supported when you are rendering forms via the RenderViewHelper.
Luckily, there is a solution for your problem: use the ‘overrideConfiguration’ parameter instead. This way, you can override the form definition within your template. Provide an according array as shown in the example below.
<formvh:render persistenceIdentifier="EXT:my_site_package/Resources/Private/Forms/MyForm.yaml" overrideConfiguration="{renderables: {0: {renderables: {0: {label: 'My shiny new label'}}}}}"/>
That means you can check for post-variables by TypoScript conditions and adjust the controllerAction (and view) accordingly. The show / detail action is not processing the form usually, so it's logical that another action has to be assigned. I'm not sure in the moment if it does matter if double opt-in or a confirmation page shall be shown, that might depend on the form-extension.
After some hours of experimenting i was able to solve the problem. It ist simply a matter of caching ...
Georg has implemented in news a special caching engine which ignores the config.no_cache = 1 definition in setup. So the detail view of news is always cached even when the whole installation ist set to config.no_cache = 1. So this combination seems to work:
Viewhelper in Detail.html:
<formvh:render persistenceIdentifier="EXT:myext/Resources/Private/Forms/myforms.form.yaml"/>
And this definitions in the yaml file of the form:
renderingOptions:
controllerAction: detail
addQueryString: true
submitButtonLabel: Absenden
additionalParams:
no_cache: 1
identifier: myForm
label: 'myLabel'
type: Form
prototypeName: myPrototype
This renders the whole page without cache which is not optimal. It would be better when only the news entry is rendered without cache. and there is the problem, that in many installations the parameter 'disableNoCacheParameter' is set in the localconfiguration file which disallowes no_cache=1 in urls.
So i looked for an other - better - possibility to work around this problem.
First make a new fluid template anywhere in your resources folder with the modified viewhelper from above:
<formvh:render persistenceIdentifier="{settings.persistenceIdentifier}"/>
Then write a typoscript like this:
lib.embeddedForm = COA_INT
lib.embeddedForm {
10 = FLUIDTEMPLATE
10 {
file = EXT:myext/Resources/Private/Forms/myForm.html
settings {
EXT:myext/Resources/Private/Forms/myforms.form.yaml
}
extbase {
pluginName = Formframework
controllerExtensionName = Form
controllerName = FormFrontend
controllerActionName = perform
}
}
}
And final you can embed the form with
<f:cObject typoscriptObjectPath="lib.embeddedForm" />
as COA_INT in the news template. This disables the caching of the form.
Perhaps it helps ...

How to make a single site page with gravstrap?

I am using the theme gravstrap for Grav CMS.
I want to make a single page website, like in this example :
http://gravstrap.diblas.net/gravstrap-theme-simple-page-example
I looked at the brief blog post explaining how to do it and also at the source code example on the project git repo.
I am having a hard time to undertand what to do exactly because what the blog-post says seems quite different than what I see in the example (especially how to link pages to menu items with the id thing).
I finally got it working :
Create a page with the template page_navbar_interne, create sub-pages as modular, each sub-page will be section.
By default sections will be ordered by the names of the folders. You can hardcode the order by adding this in the Frontmatter (expert mode) :
title: Single page website
published: true
slug: single-page-slug
content:
items: '#self.modular'
order:
by: default
dir: asc
custom:
- _header
- _mySection2
- _myOtherSection
To display the menu to navigate to the sections, you have to use navbar2 instead of navbar1, in the header module.
[g-navbar id="navbar2" name=navbar2 fixed=top centering=none brand_text="…" render=false]
[g-navbar-menu name=menu0 alignment="center" onepage=true attributes="class:highdensity-menu"][/g-navbar-menu]
[g-navbar-menu name=menu1 icon_type="fontawesome" alignment="right" ]
[g-link url="…" icon_type="fontawesome" icon="…"][/g-link]
…
[/g-navbar-menu]
[/g-navbar]

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!

How to create a setting for a simple wordpress plugin?

I've created this simple plugin and it removes admin links menu from admin panel.
<?php
/*
Plugin Name: admin menu remover
Description: Remove the admin menus just by a single plugin installation
Version: 1.0
Author: Author
Author URI: http://URI_Of_The_Plugin_Author
License: A "Slug" license name e.g. GPL2
*/
function remove_links_menu() {
remove_menu_page('index.php'); // Dashboard
remove_menu_page('edit-comments.php'); // Comments
remove_menu_page('themes.php'); // Appearance
//remove_menu_page('plugins.php'); // Plugins
remove_menu_page('tools.php'); // Tools
remove_menu_page('options-general.php'); // Settings
remove_menu_page('users.php'); // Users
}
add_action( 'admin_menu', 'remove_links_menu' );
?>
It removes 6 menus instantly after the installation. 1 line (plugins) is commented out.
Now I want to add setting option to the plugin where the user would be able to select which menu should be removed.
There should be a check box on the plugin setting where we can select which menu should be shown and hidden.
you can save the options in the _options table using update_option( $option, $new_value )
then you can use get_option( $option, $default ) to read the value from the database.
You'll have to be a little carefull when naming your option so it won't conflict with other options names (use of a prefix should fix this)

Remove "Browse" button from TinyMCE's "Insert Link" dialog when using MoxieManager

I have correctly configured MoxieManager to be integrated with TinyMCE and all works fine. But I'd like to remove the "browse" button (which opens the MoxieManager dialog) from the "Insert link" dialog.
So from the following screenshot, the green should stay but the red should go.
Self answer, but I guess it will be helpful to other people as well.
Each TinyMCE plugin usually has a JS file located under plugins/[plugin_name]/plugin.js (or plugin.min.js, depending on if you are using the minified version). Those plugins usually call the editor.windowManager.open(), passing an object of configuration options to be applied to the newly opened window.
One of the values this object can have is body which is an array of the items to be displayed in the dialog. Each item has some options to be configured on its own, including the type property.
In the below example, I have used plugins/link/plugin.js to show the difference needed to replace the (default) text field with the file browser button - with the standard text field without the browse button.
win = editor.windowManager.open({
// ...
body: [
{
name: 'href',
type: 'filepicker',
filetype: 'file',
// ...
},
// More code follows here
And the new version:
win = editor.windowManager.open({
// ...
body: [
{
name: 'href',
type: 'textbox',
filetype: 'file',
// ...
},
// More code follows here
Or, if you don't want to change the source .. say you're using a minified version etc, you can disable it via CSS:
div[aria-label="Insert link"] .mce-btn.mce-open {
display: none;
}
add it to you config
file_picker_types: 'media image'
file_picker_types
This option enables you to specify what types of file pickers you need
by a space or comma separated list of type names. There are currently
three valid types: file, image and media.
https://www.tiny.cloud/docs/tinymce/6/file-image-upload/#file_picker_types