[TYPO3-dev] Dynamic path in $TCA

Vivian Pennel vpennel at iocean.fr
Fri Mar 27 14:27:29 CET 2009


I've finished with the following code (which needs improvement but 
works) in extTables.php :

=========
if(!empty($_GET['edit']['pages'])) {
    foreach($_GET['edit']['pages'] as $uid=>$cmd){
        if($cmd == 'edit') { /** Function mod allow to create more than 
one page so .. */
            $pid = $uid; /** in edit mod there is only ONE uid **/
        }
    }
}
if(!empty($pid) && isset($pid)) {
    $destinationPath = 
realpath(dirname(__FILE__)).'/../fileadmin/user_upload/'.$pid;  /* 
method to get PATH needs improvement  (typo3  API ?) */
    if(!file_exists($destinationPath)){
        t3lib_div::mkdir($destinationPath);
    }
}
$GLOBALS['TCA']['pages']['columns']['media']['config']['uploadfolder']  
    = 'fileadmin/user_upload/stif/'.$pid;
=========

Thanks for your help.

Vivian Pennel a écrit :
> Hello Benjamin,
> Thanks for your answer.
> Based on this, i've tried to do this (i would like to avoid to modifiy 
> typo3 core if i can) in extTables.php :
>
> $page_array = t3lib_div::_GP(['edit']['pages']);
> if(!empty($page_array) && is_array($page_array) {
>    foreach($page_array as $uid=>$cmd){
>        $pid[] = $uid;
>    }
> }
> $GLOBALS['TCA']['pages']['columns']['media']['config']['uploadfolder']  
>    = 'fileadmin/user_upload/stif/'.$pid[0];
>
> It seems to work nicely but maybe i've miss something. The only 
> problem is that typo3 does not auto create destination directory.
> But i can do a test on PATH and use t3lib_div::mkdir() to solve this 
> problem i think.
>
>
>
>
>
> Benjamin Mack a écrit :
>> Hey Vivian,
>>
>> sounds like a nice idea, however this is currently not possible that 
>> way, but it'd be great if you'd create a feature request in the BT or 
>> even code it yourself and send the feature to the core list so we can 
>> get it in the next version.
>>
>> For now, I could imagine to have a very hacky way to get it done 
>> right now, would be to modify the TCA in the extTables.php based on 
>> PHP conditions, I had this in one installation to modify the output 
>> of the TCEforms:
>>
>> =========
>> if ($_REQUEST['id'] == 115 || strpos($_REQUEST['returnUrl'], 
>> 'id=115')) {
>>     $GLOBALS['TCA']['tx_cal_event']['ctrl']['title'] = 'Publikationen';
>>     $GLOBALS['TCA']['tx_cal_category']['ctrl']['title'] = 'Kategorien';
>> }
>> ==========
>>
>> I hope you can get the trick and start off, if you need it "quick and 
>> dirty", however I'd recommend looking into the t3lib class where the 
>> uploadfolder variable is used and change it accordingly to that.
>>
>> All the best,
>> Benni.
>> _______________________________________________
>> TYPO3-dev mailing list
>> TYPO3-dev at lists.netfielders.de
>> http://lists.netfielders.de/cgi-bin/mailman/listinfo/typo3-dev
>>   
>
>
>






More information about the TYPO3-dev mailing list