TYPO3 10.4: How can you add another dropdown field to the appearance tab of an content element? - typo3

I want to add more dropdown fields to the appearance tab for editing content elements.
How can I achieve this?
I've tried to add more layouts for the pageTs but that doesn't work. Also couldn't find more on this on the internet.

You can't do this via the backend. You will need to extend the TCA (e.g. in your sitepackage extension).
In your extension:
Add the field in ext_tables.sql
Extend the TCA in Configuration/TCA/Overrides/tt_content.php:
add new fields to the columns
Add the new fields to the visible fields
Add the new fields to the appropriate palette
Tip: You can look at the active TCA configuration for tt_content in the TYPO3 backend Configuration | Globals['TCA']
If you want to place the new field after an existing field, e.g. space_before_class, check which palette this is in ('frames') and place it in that.
Example:
ext_tables.sql:
CREATE TABLE tt_content(
my_new_field TINYINT(1) UNSIGNED DEFAULT '0' NOT NULL
);
Configuration/TCA/Overrides/tt_content.php
$fields = [
// new field
'my_new_field' => [
// title of the field
// alternatively, just use a string, but putting the string in
// language file eases translations
'label' => 'LLL:EXT:myextension/Resources/Private/Language/locallang.xlf:tt_content.my_new_field.title',
'config' => [
// type: select
'type' => 'select',
'renderType' => 'selectSingle',
'default' => 0,
'items' => [
[
// again, better to use language label LLL here
'description',
// value
0
],
[
// another option
'description 2',
// value
1
],
],
],
],
// ...
];
// Add new fields to table:
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns('tt_content', $fields);
// Add new field to palette 'frames'
\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addFieldsToPalette(
'tt_content',
'frames',
'my_new_field',
'before:frame_class'
);
Resources:
extend TCA: https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/ExtensionArchitecture/HowTo/ExtendingTca/Examples/Index.html
TCA: columns field types: https://docs.typo3.org/m/typo3/reference-tca/main/en-us/ColumnsConfig/Index.html
select types: https://docs.typo3.org/m/typo3/reference-tca/main/en-us/ColumnsConfig/Type/Select/Index.html
For the rest of the options, refer to the TCA Reference: https://docs.typo3.org/m/typo3/reference-tca/main/en-us/Index.html

If you could live just with more options to the given fields you can do it in the BE without programming / extending the TCA (Sybille's answer).
Extending the given list of select options for the existing fields is possible with some page/user TSConfig like:
TCEFORM.tt_content.layout.addItems {
20 = additional layout 1|nyt layout 1|neues Layout 1|...
25 = additional layout 2|nyt layout 2|neues Layout 2|...
}
TCEFORM.tt_content.frame_class.addItems {
50 = frame-class-50
55 = frame-class-55
}
Of cause this needs a handling in the rendering of the CEs.
Depending on the TYPO3 version and the active rendering there are different places to handle this.
Without FLUID rendering it needs some edits in the typoscript, with FLUID you need to override the appropriate file (layout/template/partial) where the field (here: layout and frame_class) is handled.

Related

A checkbox data type and showing more than one row per "row" (in Adazzle react-data-grid)

We'd like to use React Data Grid from Adazzle (as mentioned in the tag with this question) now that we're using React (16.xx) and the older jsGrid is less appealing.
Two questions:
Our old jsGrid had a data type to include in the grid called Checkbox. This was immensely helpful. I haven't found a similar type in the React Grid. Have I just missed it or is it not a part of the library?
In each row, in some columns, we'd like to actually have two rows of data inside the column -- i.e., two lines of text separated by carriage return. But the react-data-grid demos only seem to show one line per column. Is this a limitation, or can we use CSS in the values inside columns?
Is there search included for the rows shown in the table at any given point in time?
I will provide answer to your question part by part
1) In react-data-grid column you can include a checkbox by using the formatter
attribute that is specified while the columns are defined.
Consider the following example
let columns = [
{
key: 'name',
name: 'Name',
resizable: true,
width: 100
},
{
key: 'checkbox',
name: 'CheckBox',
formatter:checkBoxFormatter,
resizable: true,
width: 100
}
]
class checkBoxFormatter extends React.Component {
render() {
return (
<div>
<CheckBox></Checkbox> //Provide your checkbox code here
</div>
)
}
}
2)You can exapand the rows for that you need to use getSubRowDetails and onCellExpand attributes of ReactDataGrid component .For example refer this documentation
3)Search is available for filtering .For example refer this documentation

How to add filter form to magento admin grid?

How to add a filter form as like report->sales->orders to my custom module. The filtered result should be shown in grid table.I have made the data to be displayed in the grid.
In Grid.php, where you are creating columns of grid, you need to add 'filter'=>true. Like below:
$this->addColumn('COLUMN_NAME', array(
'header' => Mage::helper('MODULE_NAME')->__('COLUMN_HEADER_TEXT'),
'index' => 'COLUMN_NAME',
'sortable' => true, // make sortable column
'filter' => true // make filter column
));
Hope will help!

Web2py : SQLForm labels option not overriding labels in view

I have a simple SQLform, where I'm trying to override the labels so they are more meaningful to the user :
form = SQLFORM(db.UserData, submit_button='Report now !', labels =
{'title':'Article Title', 'link':'Link to article',
'htmlcontent':'Content in HTML format', 'textcontent':'Content in text
format', 'source':'Your name', 'imageurl':'Image to the article',
'briefdescription':'Brief article excerpt', 'iscontentavailable':
'Ignore this'})
The labels for htmlContent, imageurl, briefdescription & textcontent are not being replaced.
Any idea what I should be checking or where I might be going wrong ?
You can get a easy name for your fields when defining your table, with labels:
db.define_table('system',
Field('version', label='System Version', length=4),
Field('db', label='System Database', length=10),
Field('modules', label='Modules loaded', length=50)
)
and Using placeholder HTML5 property with a custom form, you can put a tip into the textboxes:
{{=form.custom.begin}}
{{form.custom.widget.title['_placeholder']='Article Title'}}
{{form.custom.widget.link['_placeholder']='Link to article'}}
....
{{=form.custom.end}}
To add a label you can use jquery:
$('#title').val($('#title').val() + 'Article Title');

ExtJS4: Add field to form panel but not want it to be rendered by panel

I have a static html form layout where i add extjs form fields using the "renderTo" config. In order to have form validation and simple submit methods i want to add the fields to a form panel. As the layout is managed by the html frame i don't want the form to be rendered by the panel (panel has html frame as contentEl and this should be used as is).
In extjs3 i could achieve this by adding the field not to the panel but to the BasicForm (formpanel.getForm().add(...)) but in extjs4 this method seems to be gone.
How can i do this using extjs4?
Thanks in advance.
Since you already have a Panel that uses the contentEl to render HTML into its body, I recommend to stick with this approach:
Replace the panel with an Ext.form.Panel instance - the configuration, particularly the contentEl config - can remain unchanged.
The code provided here will override a standard Ext class (Ext.layout.Layout) and introduce support for a 'renderItemTo' config property on child items of any Ext container or panel instance (including Ext.form.Panel).
The value of the config property should be the ID of an already rendered DOM node, e.g. a DIV element that is part of the HTML fragment used in as the contentEl of the parent container's body.
Ext.require(['Ext.layout.Layout'], function() {
Ext.override(Ext.layout.Layout, {
renderItem: function (item, target, position) {
if(item.renderItemTo) {
// render 'renderItemTo' components into the specified DOM element
item.render(item.renderItemTo, 1);
// don't allow container layout to seize the component
item.layoutManagedHeight = 2;
item.layoutManagedWidth = 2;
} else {
// just use standard Ext code for non-renderItemTo components
this.callOverridden(arguments);
}
},
isValidParent: function(item, target, position) {
// signal Ext that we are OK with were our 'renderItemTo' component is right now
// otherwise it would get moved during the layout process
return item.renderItemTo ? true : this.callOverridden(arguments);
}
});
});
Usage:
var panel = Ext.create('Ext.form.Panel', {
contentEl: 'form', // the DOM element ID that holds the HTML fragment for the body
title: 'My FormPanel with special FX',
items: [
{
xtype: 'textfield',
renderItemTo: 'text1', // the ID of a DOM element inside the HTML fragment
fieldLabel: 'Label 1',
},
{
xtype: 'textfield',
renderItemTo: 'text2', // the ID of a DOM element inside the HTML fragment
fieldLabel: 'Label 2'
}
]
});
I uploaded a working example to JSFiddle (note: resize the window if you experience a render problem - this is related to JSFiddle, not my override).
After digging through the layout system of ExtJS 4.1 i implemented a custom layout which moves the items after rendering to the desired position in the fixed markup. The result is the same as for the ExtJS 4.0.7 version from this thread. It seams to work for the ExtJS standard fields. I have some problems with my custom fields though.
Ext.define('Ext.ux.layout.Fixed', {
extend: 'Ext.layout.container.Auto',
alias: 'layout.uxfixed',
afterRenderItem: function(item) {
// move items with renderToFixedMarkup to desired position
if (item.renderToFixedMarkup) {
var target = Ext.getDom(item.renderToFixedMarkup);
this.moveItem(item, target);
}
},
isValidParent: function(item, target, position) {
// items with renderToFixedMarkup property are always positioned correctly
return (item.renderToFixedMarkup) ? true : this.callOverridden(arguments);
}
});
It can be used by setting "layout: 'uxfixed'" on the panel and the "renderToFixedMarkup" config on the items.

ExtJs 4 dynamic form fields in nested panels aren't submitted

Let's say I have multiple nested panels (plain ones, not form.Panel) containing form fields.
The user can copy such a panel and its fields to a different panel.
I somehow need to add those newly created fields to a main formpanel so they get submitted, but don't know how.
I can't do
formpanel.add(fields)
because then they're rendered to the formpanel's body and not the panel they were in in the first place. Setting the fields' renderTo property doesn't help either.
So basically I need a way of adding a field to a normal panel (or any other component for that matter), but also adding it to a specific formpanel so its values are submitted on form submit.
Has anyone done this or could at least point me in the right direction?
You can wrap all your panels inside one form panel and all the fields inside will be submitted. I did this way with accordeons, tabpanel and normal panels deeply nested inside each other. Example:
var form = Ext.create('Ext.form.Panel', {
// form attributes goes here...
// ...
initComponent: function(){
// all your panels goes here.
this.items = [
{
xtype:'panel',
title: 'First panel',
layout: 'anchor',
frame: true,
defaults: {anchor: '100%'},
items: [
{xtype:'textfield', name: 'foo',fieldLabel: 'Foo'},
{xtype:'textfield', name: 'foo',fieldLabel: 'Bar'}
]
},
{
xtype:'panel',
title: 'Second panel',
layout: 'anchor',
frame: true,
defaults: {anchor: '100%'},
items: [
{xtype:'textfield', name: 'baz',fieldLabel: 'Baz'},
{
xtype: 'panel',
items: [/* another set of fields */]
}
]
},
];
this.buttons = [/* ... your buttons here ...*/];
this.callParent(arguments);
}
});