Results 1 to 5 of 5

Thread: Select Menu and Internationalization

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

    Default Select Menu and Internationalization

    How do you properly set up a select menu so that the dropdown choices can be viewed in a different language when a language pack is installed, but the logic still works? eg: 'Unread','Pending','Ok','Closed' are English.

    Code:
     'unread' => array
      (
                    'label' => &$GLOBALS['TL_LANG']['tl_realestate_contactor']['unread'],
                    'inputType'            => 'select',
                     'options'                => array('Unread','Pending','Ok','Closed'),
                     'eval'                    => array('tl_class'=>'w50'),
    	'filter'                   => true,
    	'sorting'                 => true,
    	'save_callback'         => array
    	(
    	    array('tl_realestate_contactor', 'markAsRead')
    	),
                  'flag'                    => 12		
      ),
    I use the dropdowns in code, for example
    Code:
    public function markAsRead($varValue)
    {
    	if($varValue == "Unread")
    	{
    	$varValue = "Pending";
    	}
    return $varValue;
    }

    EDIT: Why the heck does my Code always go spastic when I cut/paste/post it wrapped in the code tags???

  2. #2
    User
    Join Date
    08-10-09.
    Posts
    31

    Default Re: Select Menu and Internationalization

    Ehm, is it me, but you can use language strings... So you can use values, such as unread, pending and then define display value for this for each language in languages/en/tl_.php
    Jaap Jansma

    Walk Wise Webdesign

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

    Default Re: Select Menu and Internationalization

    Code:
     'options'                => array($GLOBALS['TL_LANG']['tl_realestate_contactor']['A'],$GLOBALS['TL_LANG']['tl_realestate_contactor']['B'],$GLOBALS['TL_LANG']['tl_realestate_contactor']['C'],$GLOBALS['TL_LANG']['tl_realestate_contactor']['D']),
    Code:
    $GLOBALS['TL_LANG']['tl_realestate_contactor']['A'] = 'Unread';
    $GLOBALS['TL_LANG']['tl_realestate_contactor']['B'] = 'Pending';
    Code:
    public function markAsRead($varValue)
    {
       if($varValue == $GLOBALS['TL_LANG']['tl_realestate_contactor']['A'])
       {
       $varValue = $GLOBALS['TL_LANG']['tl_realestate_contactor']['B'];
       }
    return $varValue;
    }
    Like so?

  4. #4
    User
    Join Date
    06-19-09.
    Posts
    328

    Default Re: Select Menu and Internationalization

    Hi ramjet

    you need to use the 'reference' configuration option

    from:
    http://www.contao.org/reference.html#fields

    "Array that holds the options labels. Typically a reference to the global language array."

    Some time ago I wrote an article that covers also this topic

    It is here http://zedseries.blogspot.com/2009/1...e-options.html

    take a look at 'printable' field in tl_article dca or 'rgxp' in tl_form_field dca

    hope this helps
    Consulenza Contao CMS https://www.intco.it

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

    Default Re: Select Menu and Internationalization

    Thats absolutely perfect ga.n, thank you.
    I'll have a good look over your site in the next few days (i did a while ago but most things were way over my head then.... hopefully I'll be a bit more clued in now)
    Cheers very much, murray :D :D

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
  •