I want to show a grid or editable table in my tab in the admin section
I managed to do the module and three tabs are been displayed .In one of the tab i want to show a editable grid i.e in the CHECKS tab
As shown in the below image,in the chek tab section i want to show a grid
In the constructor of my admin controller of my module ()
ie in addhealthcheckconfig\controllers\admin\HealthCheckConfigController.php
I am setting the field options to populate the tab ,below is my code:
$this->fields_options = array(
'appearance' => array(
'title' => $this->l('Manage your Health Check '),
'icon' => 'icon-html5',
'tabs' => array(
'TAB1' => $this->l('SUPPORT_GROUPS'),
'TAB2' => $this->l('CHECKS'),
'TAB3' => $this->l('REPORT RECIPIENTS'),
),
'fields' => array(
'SUPPORT_GROUPS' => array(
'title' => $this->l('SUPPORT GROUPS'),
'hint' => $this->l('Manage your Support Groups here'),
'type' => 'fields_list',
'name' => 'PS_LOGO',
'tab' => 'TAB1'
),
'CHECKS' => array(
'title' => $this->l('LIST OF AVAILABLE CHECKS '),
'hint' => $this->l('List of Available checks will be displayed here !!'),
'type' => 'text',
'list' => $this->fields_list = array(
'code' => array(
'title' => $this->l('code'),
'align' => 'text-center',
'remove_onclick' => true,
'search' => false,
),
'description' => array(
'title' => $this->l('description'),
'align' => 'text-center',
'remove_onclick' => true,
'search' => false,
),
'category' => array(
'title' => $this->l('category'),
'align' => 'text-center',
'remove_onclick' => true,
'search' => false,
),
),
'tab' => 'TAB2'
),
'REPORT_RECIPIENTS' => array(
'title' => $this->l('REPORT RECIPIENTS '),
'hint' => $this->l('List of Available checks will be displayed here !!'),
'tab' => 'TAB3'
),
) ));
In the TAB2 Section i am not sure what i need to put in the 'type' section , I tried with list , but yet I can not achieve what I am trying to do , also i am not sure how to assign the $this->fields_list to that type correctly
How to achieve this editable db grid in my tab ?
How can i create one-to-many relationship with my custom module. And add subpanel to Campaign module
Campaign vardefs
$dictionary["Campaign"]["fields"]["costs"] =
array (
'name' => 'costs',
'type' => 'link',
'relationship' => 'campaign_costs',
'module'=>'Costs',
'bean_name'=>'Costs',
'source'=>'non-db',
'vname'=>'LBL_AUCTIONS',
);
$dictionary['Campaign']['relationships']['campaign_costs'] =
array (
'lhs_module'=> 'Campaigns',
'lhs_table'=> 'campaigns',
'lhs_key' => 'id',
'rhs_module'=> 'Costs',
'rhs_table'=> 'cots',
'rhs_key' => 'campaign_id',
'relationship_type'=>'one-to-many'
);
layout_defs properties
$layout_defs["Campaigns"]["subpanel_setup"]["campaign_costs"] = array (
'order' => 2,
'module' => 'Costs',
'subpanel_name' => 'default',
'sort_order' => 'desc',
'sort_by' => 'date_entered',
'title_key' => 'LBL_SUBPANEL_COSTS',
'get_subpanel_data' => 'costs', //имя поля link
'top_buttons' =>
array (
0 =>
array (
'widget_class' => 'SubPanelTopButtonQuickCreate',
),
1 =>
array (
'widget_class' => 'SubPanelTopSelectButton',
'mode' => 'MultiSelect',
),
),
);
Custom module vardefs
$dictionary['Costs']['fields']['campaign_id'] =
array (
'required' => false,
'name' => 'campaign_id',
'vname' => '',
'type' => 'id',
'massupdate' => 0,
'importable' => 'true',
'audited' => 0,
'len' => 36,
);
$dictionary['Costs']['fields']['campaign_name'] =
array (
'required' => false,
'source' => 'non-db',
'name' => 'campaign_name',
'vname' => 'LBL_CAMPAIGN_NAME',
'type' => 'relate',
'massupdate' => 0,
'comments' => '',
'help' => '',
'audited' => 1,
'len' => '100',
'id_name' => 'campaign_id',
'ext2' => 'Campaigns',
'module' => 'Campaigns',
'rname' => 'name',
'studio' => 'visible',
);
The relationship is added, but subpanel doesn't appear at campaigns module.
In your $dictionary["Campaign"]["fields"]["costs"], change bean_name from Costs to Cost.
I take it you have enabled the subpanel in the admin-menu? (index.php?module=Administration&action=ConfigureTabs)
Does your error-logs say anything?
First of all excuse my bad english.
I got a problem with my select-field in the BE. I would like to prefill (preselect) all of the available items.
Code in ext_tables.php:
'teilnehmer' => array(
'exclude' => 0,
'label' => 'LLL:EXT:kiwanisext/Resources/Private/Language/locallang_db.xlf:tx_kiwanisext_domain_model_veranstaltung.teilnehmer',
'config' => array(
'type' => 'select',
'foreign_table' => 'fe_users',
'MM' => 'tx_kiwanisext_veranstaltung_user_mm',
'size' => 10,
'autoSizeMax' => 30,
'maxitems' => 9999,
'multiple' => 0,
'wizards' => array(
'_PADDING' => 1,
'_VERTICAL' => 1,
'edit' => array(
'type' => 'popup',
'title' => 'Edit',
'script' => 'wizard_edit.php',
'icon' => 'edit2.gif',
'popup_onlyOpenIfSelected' => 1,
'JSopenParams' => 'height=350,width=580,status=0,menubar=0,scrollbars=1',
),
'add' => Array(
'type' => 'script',
'title' => 'Create new',
'icon' => 'add.gif',
'params' => array(
'table' => 'fe_users',
'pid' => '###CURRENT_PID###',
'setValue' => 'prepend'
),
'script' => 'wizard_add.php',
),
),
),
),
I found nothing helpful in the documentation.
Any hint, tip or help will be much appreciated!
Its not possible to do that with plain TCA config, afaik. You can however define a default value wich will be selected (if none is defines, 1st item will be selected).
'default' => 'myValue'
But to preselect multiple values at once, you have to use JavaScript I guess.
This code worked for me in typo3 6.2. I have a selectbox filled with database records.
I want the records with ID's 1 ans 2 to be preselected in the selectbox:
'thematique' => array(
'exclude' => 0,
'label' => 'LLL:EXT:dk_actus/locallang_db.xml:tx_dkactus_thematique',
'config' => array(
'type' => 'select',
'foreign_table' => 'tx_dkactus_thematique',
'foreign_table_where' => 'ORDER BY tx_dkactus_thematique.uid',
'size' => 10,
'minitems' => 0,
'maxitems' => 99,
'default' => '1,2',
),
),
I'm trying to turn a huge configuration array in PHP, that looks like this
$config['festival'] =
array
(
'title' => 'USF Tango Festival',
'tableLayout' => array
(
'registration' => array
(
array('firstName','text'),
array('lastName','text'),
array('phone','text'),
array('email','text'),
array('hearAboutFestival','text'),
array('danceAs','enum(\'Leader\', \'Follower\', \'Both\')'),
array('student','tinyint(1)')
),
'experience' => array
(
array('options','text'),
array('lunchMeat','enum(\'Ham\',\'Turkey\',\'Vegetarian\')'),
array('lunchBread','enum(\'White\',\'Wheat\')'),
array('dinnerPref','enum(\'Chicken\',\'Beef\',\'Vegetarian\')')
)
),
'pageLayout' => array
(
'registration' => array
(
'jqueryRules' =>
<<<EOT
'firstName': 'required',
'lastName': 'required',
'phone': {
required: true,
phoneUS: true
},
'email': {
required: true,
email: true
},
'danceAs': 'required',
'partner': 'required',
'partnerMatching': {
required: function() {
return $("input[name='partner']").val() == 0;
}
},
'partnerName': {
required: function() {
return $("input[name='partner']").val() == 1;
}
}
EOT
,
'inputs' => array
(
array
(
'type' => 'text',
'name' => 'firstName',
'fullName' => 'First Name',
'required' => true,
'separateDiv' => false
),
array
(
'type' => 'text',
'name' => 'lastName',
'fullName' => 'Last Name',
'required' => true,
'separateDiv' => false
),
array
(
'type' => 'text',
'name' => 'phone',
'fullName' => 'Phone number',
'required' => true,
'separateDiv' => false
),
array
(
'type' => 'text',
'name' => 'email',
'fullName' => 'Email address',
'required' => true,
'separateDiv' => false
),
array
(
'type' => 'text',
'name' => 'hearAboutFestival',
'separateDiv' => false,
'fullName' => 'How did you hear about the festival?',
'required' => false
),
array
(
'type' => 'select',
'name' => 'danceAs',
'fullName' => 'You dance as a...',
'required' => true,
'separateDiv' => false,
'options' => array(array('leader','Leader'),array('follower','Follower'),array('both','Both'))
),
array
(
'type' => 'checkbox',
'name' => 'student',
'value' => '1',
'separateDiv' => false,
'fullName' => 'I am a student',
'required' => false
)
)
)
and
'options' => array
(
'busMilonga' => array
(
'price' => 20,
'student' => false,
'name' => 'Tango on the Town Bus milonga',
'description' => 'A bus milonga!'
),
'thursdayMilonga' => array
(
'price' => 10,
'student' => false,
'name' => 'Thursday Kickoff Milonga',
'description' => 'The un-official kick off milonga!'
),
'saturdayPass' => array
(
'price' => 90,
'student' => true,
'name' => 'Saturday pass',
'description' => 'Includes all Saturday workshops and milongas'
),
'sundayPass' => array
(
'price' => 80,
'student' => true,
'name' => 'Sunday pass',
'description' => 'Includes all Sunday workshops, the jam session, and milonga'
),
'milongaPass' => array
(
'price' => 70,
'earlyBird' => 50, //array(50,60),
'student' => true,
'name' => 'Milonga Pass',
'description' => 'Includes entrance to all night milongas'
),
'dinnerPass' => array
(
'price' => 20,
'student' => false,
'name' => 'Dinner pass',
'description' => 'Includes Saturday dinner'
),
'lunchPass' => array
(
'price' => 10,
'student' => false,
'name' => 'Saturday lunch',
'description' => 'Includes lunch on Saturday'
)
),
'info' => array
(
'instructors' => array('Instructors'),
'hour' => array('10','11','12','01','02','03'),
'min' => array('15','30','45','00'),
'tod' => array('AM','PM'),
'day' => array('Friday','Saturday','Sunday'),
'level' => array('Beginner','Intermediate','Advanced'),
'place' => array('REC 107','REC 033','REC 005'),
'sessions' => array
(
3, // days
array
(
'Friday', // day name
3, // sessions on this day
array
(
3, // workshops in session
'1100AM' // time
),
array
(
3,
'0100PM'
),
array
(
1,
'0230PM'
) // 1,4
),
array('Saturday', // 2,0
3, // 2,1
array(1,'1030AM'), //2,2
array(3,'1145AM'), // 2,3
array(3,'0145PM') // 2,4
),
array
(
'Sunday', // 3,0
3, // 3,1
array(1,'1115AM'), // 3,2
array(3,'1230PM'), // 3,3
array(3,'0230PM') // 3,4
)
)
)
into a database. I'm thinking I could make a few tables, titled something like config.event.festival but then it would get cumbersome since I would have to create a table for each array under the array...
I want to avoid using JSON encoding or serializing, so that I keep the data all relational and clean looking but I don't know any other way other than just keeping one big configuration file rather than a database.
Assuming the sample you provided represents a truncated view of your whole data structure, this could be done with three tables.
festival
festival_id
title
layout
layout_id
festival_id
layout_type_id
type
name
fullName
required
separateDiv
layout_type
layout_type_id
name
The festival table would keep your high-level meta data about the event page. The layout table would contain meta data about each of the elements on the page. And finally, the layout_type table would allow you to identify different element types that should be on a given page.
This should get you started and allow you to modify as necessary.
Try this:
// To save multidimensional array into database:
$confIn = serialize($config);
// Save serialized config into database
// To get it from database, query the database and get serialized value
$confOut = serialize($confIn);
// Check if its ok
var_export($confOut);
More about serialize function: Serialize
The good thing with this approach is you can use only one column in database.
Hope this helps!
Is it possible to add a page browser (browse_links) like this to a front end extension?
Sure. Add the 'suggest' wizzard in the TCA for that field:
'yourlink' => array (
'label' => 'LLL:EXT:yourextension/locallang_general.xml:yourlink',
'config' => array (
'type' => 'group',
'internal_type' => 'db',
'allowed' => 'pages',
'size' => '1',
'maxitems' => '1',
'minitems' => '0',
'show_thumbs' => '1',
'wizards' => array(
'suggest' => array(
'type' => 'suggest',
),
),
),
),