Results 1 to 6 of 6

Thread: DCA foreignKey conditions

  1. #1

    Beitrag DCA foreignKey conditions

    Hi there,
    for DCA you can have a key 'foreignKey' => TableName.FieldName
    e.g.
    Code:
    'author' => array
    (
        [...]
        'foreignKey'              => 'tl_user.name',
    ),
    How can I achieve this with some conditions. like say to select all user with german langauge
    Code:
        'foreignKey'              => 'tl_user.name;language=de',
    which file in core does this foreignKey is return into array();
    Thanks
    OM MANI PEME HUNG! how many has to die for freedom and dignity. Save this world

  2. #2
    New user cliffen's Avatar
    Join Date
    10-18-13.
    Location
    Lüneburg
    Posts
    22

    Default

    Hi,

    i think that's not possible. Use the 'options_callback', to define a custom DB statement with filters and ordering.

    Greetings, Cliff
    Extensions :: Github :: No support via PM.

  3. #3

    Default

    OK. thats what everyone is saying, but there ought to be a way. Do you know by the way where is this array with value (from tableName.fieldName) is read from DB?
    OM MANI PEME HUNG! how many has to die for freedom and dignity. Save this world

  4. #4
    New user cliffen's Avatar
    Join Date
    10-18-13.
    Location
    Lüneburg
    Posts
    22

    Default

    Have a look at DC_Table ... there yout can find some places where "foreignKey" is read from DCA.
    Extensions :: Github :: No support via PM.

  5. #5

    Default

    Just for reference:
    Its rendered inside core/library/Contao/Widget.php

    Code:
    ...
    		// Foreign key
    		elseif (isset($arrData['foreignKey']))
    		{	
    
    			$arrKey = explode('.', $arrData['foreignKey'], 2);	
    		
    			$objOptions = \Database::getInstance()->query("SELECT id, " . $arrKey[1] . " AS value FROM " . $arrKey[0] . " WHERE tstamp>0 ORDER BY value");
    			$arrData['options'] = array();
    
    			while($objOptions->next())
    			{
    				$arrData['options'][$objOptions->id] = $objOptions->value;
    			}
    		}
    ...
    OM MANI PEME HUNG! how many has to die for freedom and dignity. Save this world

  6. #6
    New user cliffen's Avatar
    Join Date
    10-18-13.
    Location
    Lüneburg
    Posts
    22

    Default

    Thanks
    Extensions :: Github :: No support via PM.

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
  •