Results 1 to 8 of 8

Thread: Smart Fields in Back End (Solved)

  1. #1
    New user
    Join Date
    09-24-09.
    Posts
    13

    Default Smart Fields in Back End (Solved)

    Hello,

    I'm new here and my general language is Russian, sorry if I'm writing like a barbarian

    I want to create complicated functionality:
    I need one Field on my Back End Form to be connected to different table..

    Example: I'm created BackEnd Module of Engineers with all info, address, name, professional qualifications.. and I need to add multiply fields for Areas Coverage (Post Code coverage).. just list of all post codes that he covers.. and in Database it is additional table... By default in this module I'm using engineers table, but for this field needed additional table, PostCodeCoverage which consist of EngineerID and Post code (2 fields)..

    And the code, I'm downloaded MultiText Wizard module, it shows fields properly and adding new, but where I need to insert proper code to give TL idea where to store and read content?!
    Code:
    		'postCodeCoverage' => array
    		(
    			'label'     => &$GLOBALS['TL_LANG']['tl_js_postCodeCoverage']['postCodeCoverage'],
    			'inputType' => 'multitextWizard',
    			'eval'      => array
    			(
    				'mandatory' => false,
    				'doNotSaveEmpty'=>true,
    				//'style'=>'width:142px;',
    				'columns' => 1, 
    				'labels' => array
    				(
    					&$GLOBALS['TL_LANG']['tl_js_postCodeCoverage']['postCode']
    				)
    			)
    		)
    Hopefully somebody can understand what I want and be able to help me. Thanks.

    Rad.

  2. #2
    Experienced user
    Join Date
    06-20-09.
    Posts
    1,311

    Default Re: Smart Fields in Back End

    The way I would go about it is just create a table of postcodes (and information relative exclusively to that postcode) with no engineer details in that table.
    Then in your engineers DCA add a field "coverage" , use foreignKey and a multiple select to create a multi-selectable dropdown menu of postcodes for your existing engineer record -which I imagine are stored serialized in the "coverage" field (I've not used a multiple select box).

    Code:
            'coverage' => array
            (
                'label'                   => &$GLOBALS['TL_LANG']['tl_Your_Engineers_Table']['coverage'],
    			'inputType'               => 'select',
    			'foreignKey'              => 'tl_Your_Postcode_Table.postcode',
    			'eval'                    => array('mandatory'=>true, 'multiple'=>true, 'includeBlankOption'=>true, 'tl_class'=>'w50' )
            ),
    You could use multiple checkboxes if you prefer.
    This way your engineers coverage area is stored and editable in his record, not elsewhere.

    You'll need to add a postcode DCA (tl_Your_Postcode_Table.php), a postcode Language file (tl_Your_Postcode_Table.php),
    add the tl_Your_Postcode_Table to your Config/database.sql, and register it all your Modules Config/config.php with something like
    Code:
    //backend module
    $GLOBALS['BE_MOD']['content']['Your_Engineers_Module'] = array(
    	'tables' => array('tl_Your_Engineers_Table','tl_Your_Postcode_Table,'tl_Any_Other_Table),
    	'icon'   => 'system/modules/Your_Engineers_Module/html/iconEngineer.gif'
    );

    You could also add into your Engineers DCA in the global operations area
    Code:
               'postcode' => array
                (
                   'label'               => &$GLOBALS['TL_LANG']['tl_Your_Engineers_Table']['postcode'],
                   'class'               => 'header_new',
                   'href'                => 'table=tl_Your_Postcode_Table'
                ),
    and add the buttons into your languages/en/tl_Your_Postcode_Table.php file


    Code:
    // Buttons
    $GLOBALS['TL_LANG']['tl_Your_Postcode_Table']['new']    = array('New Postcode', 'Add a new Postcode');
    $GLOBALS['TL_LANG']['tl_Your_Postcode_Table']['edit']   = array('Edit Postcode', '');
    $GLOBALS['TL_LANG']['tl_Your_Postcode_Table']['copy']   = array('Copy Postcode', '');
    $GLOBALS['TL_LANG']['tl_Your_Postcode_Table']['delete'] = array('Delete Postcode', '');
    $GLOBALS['TL_LANG']['tl_Your_Postcode_Table']['show']   = array('Postcode details', 'Show Postcode details');
    $GLOBALS['TL_LANG']['tl_Your_Postcode_Table']['return']   = array('Return to Your_Engineers_Main Screen'', '');
    and this into the global_operations of your DCA/tl_Your_Postcode_Table.php

    Code:
            'global_operations' => array
            (
    //return to the Engineers module			
               'return' => array
                (
                   'label'               => &$GLOBALS['TL_LANG']['tl_Your_Postcode_Table']['return'],
                   'class'               => 'header_new',
                   'href'                => 'table=tl_Your_Engineers_Table'
                ),
    This adds a button at the top of the Engineers Screen, and a return button at the top of the Postcode screen.
    Also edit,copy,delete,show buttons in the Postcode Screen for each postcode record so that the postcodes table becomes editable too (it could for instance carry other fields with info on Good_Neighbourhood, Average_Rainfall, size_in_square_km etc, mad_dog_alert....that is: info about the postcode, NOT about the engineer). That way you could add new postcodes in, delete them , edit them when they change (my home postcode has recently changed), add new postcode info in as mad dogs attack engineers etc.

    Theres a bit more too it to have an editable postcode table, but that should get you going.

    And on it goes, hope that helps.
    :D

  3. #3
    Experienced user
    Join Date
    06-20-09.
    Posts
    1,311

    Default Re: Smart Fields in Back End

    Whoops, you edited while I was posting.
    I don't know anything about MultiText Wizard sorry.

  4. #4
    New user
    Join Date
    09-24-09.
    Posts
    13

    Default Re: Smart Fields in Back End

    Thanks for reply, I#m thinking i need to implement "ForeignKey" for my field somehow, if you can give me link where I can findout more about this or any ideas of using it...

    I have 2 tables setuped already one for Engineer, second for post codes with only 3 fields, id, EngineerID and PostCode.. so I need to have link from Engineers to PostCodes table .. in logic it is EngineerID, but what to do in typolight to achive this I don't know.

  5. #5
    Experienced user
    Join Date
    06-20-09.
    Posts
    1,311

    Default Re: Smart Fields in Back End

    This forum, the old forum http://www.typolight.org/forum.html, my last post and http://www.typolight.org/reference.html
    :D

  6. #6
    New user
    Join Date
    09-24-09.
    Posts
    13

    Default Re: Smart Fields in Back End

    Thanks for suggestions, but particulary for this taks, I can use MultiTextWizard, it is great! It saves many fields in one DataBase field, as compressed array automatically )

    But for my further task, I should know how to link tables to each other... I have Jobs (table), Engineer (table) and Customer (table) .. and inside Jobs I've defined fields for linking other tables, EngineerID and CustomerID ... of course this is completely the same taks as before, and I'm still have no clue how to programm this ... But thanks for your link, I've realize that I've missed major TableConfiguration Key that is vital for me CTABLE ... with onload_callback, onsubmit_callback and onsubmit_callback keys. If here was tutorial of ising more than one table this will be very helpful not only for me as I think. I has follow tutorial of creating custom module CD Collection and understand a lot of development process in typolight, but if you need something more complicated like linking 2 or 3 tables in one form this starts problems for new comers...

    I've also tryed to look at different modules, how they are built and get stacked with this ... I will try again, but will be better to have appropriate tutorial for this .. By the way, writing database.sql is also not so easy, because program that is installing your database and performs changes, example if you need create field type "text" you can define it like this:
    Code:
    `fieldName` text,
    But you in installer you will have ALTER table line because you must define as well NULL and only in uppercase!
    Code:
    `fieldName` text NULL,
    If there are already some description of "How to create your custom functionality" please let me know, or somebody should write it! For Leo: Please create more tutorials.

    I'm always lern programming by myself and for developing code in PHP I'm using php.net it is wery nicely formatted and with lots of descriptions, so everyone can do almost anything hopefully here will be the same, I like Typolight and functionality that he offer, you don't need to programm a lot to produce huge amount of work, if I was doind the same on my own it took me ages, but with Typolight only couple of weeks, working after work in free time!

  7. #7
    Experienced user
    Join Date
    06-20-09.
    Posts
    1,311

    Default Re: Smart Fields in Back End

    There were some various tutorials before the Typolight site was upgraded, but I'm damned if I can find them now sorry ... even a search doesn't reveal them.(i can't even find the CD Collection tutorial, where was that?)

    I can't really help you sorry as I'm no expert and haven't used Multitext Wizard .

  8. #8
    Experienced user
    Join Date
    06-20-09.
    Posts
    1,311

    Default Re: Smart Fields in Back End


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •