TYPO3: Force download of files added through FCE

To download the files that are added from the FCE, instead opening them in the browser, please add the following code

 

The XML structure

 

<?xml version="1.0" encoding="utf-8" standalone="yes" ?>
<T3DataStructure>
    <meta type="array">
        <langDisable>1</langDisable>
    </meta>
    <ROOT type="array">
        <tx_templavoila type="array">
            <title>ROOT</title>
            <description></description>
        </tx_templavoila>
        <type>array</type>
        <el type="array">
            <field_icon type="array">
                <tx_templavoila type="array">
                    <title>File Icon</title>
                    <sample_data type="array">
                        <numIndex index="0"></numIndex>
                    </sample_data>
                    <eType>TypoScriptObject</eType>
                    <TypoScript>
                        <![CDATA[
                        10 = COA
                        10 {
                            10 = IMAGE
                            10.file.import = uploads/tx_templavoila/
                            10.file.import.field = field_file
                            10.file.import.listNum = 0
                            10.file.ext = png
                            10.file.maxW = 135
                            10.stdWrap.typolink.parameter.cObject = COA
                            10.stdWrap.typolink.parameter.cObject {
                                10 = TEXT
                                10.field = field_file
                                10.stdWrap.wrap = uploads/tx_templavoila/|
                            }
                            10.stdWrap.typolink.jumpurl = 1
                            10.stdWrap.typolink.jumpurl.secure = 1
                            10.stdWrap.typolink.jumpurl.secure.mimeTypes = pdf=application/pdf, doc=application/msword, png=image/png, gif=image/gif, jpg=image/jpg
                        }

                        ]]>
</TypoScript>
                </tx_templavoila>
                <description></description>
            </field_icon>
            <field_header type="array">
                <tx_templavoila type="array">
                     <title>Header</title>
                     <sample_data type="array">
                          <numIndex index="0">[ Header ]</numIndex>
                     </sample_data>
                     <eType>TypoScriptObject</eType>
                     <TypoScript>
                         <![CDATA[ 
                            10 = COA
                            10{
                                10 = TEXT
                                10.data = register:tx_templavoila_pi1.parentRec.header
                                10.if.isTrue.data = register:tx_templavoila_pi1.parentRec.header
                                10.stdWrap.typolink.parameter.cObject = COA
                                10.stdWrap.typolink.parameter.cObject {
                                    10 = TEXT
                                    10.field = field_file
                                    10.stdWrap.wrap = uploads/tx_templavoila/|
                                }
                                10.stdWrap.typolink.jumpurl = 1
                                10.stdWrap.typolink.jumpurl.secure = 1
                                10.stdWrap.typolink.jumpurl.secure.mimeTypes = pdf=application/pdf, doc=application/msword, png=image/png, gif=image/gif, jpg=image/jpg
                            }
                         ]]>
                    </TypoScript>
                     <description></description>
                </tx_templavoila>
            </field_header>
            <field_file type="array">
                <tx_templavoila type="array">
                    <title>File</title>
                    <sample_data type="array">
                        <numIndex index="0"></numIndex>
                    </sample_data>
                    <eType>image</eType>
                    <TypoScript></TypoScript>
                    <preview></preview>
                </tx_templavoila>
                <TCEforms type="array">
                    <label>File</label>
                    <config type="array">
                        <type>group</type>
                        <internal_type>file</internal_type>
                        <allowed>gif,png,jpg,jpeg,xls,xlsx,zip,pdf</allowed>
                        <max_size>1024</max_size>
                        <uploadfolder>uploads/tx_templavoila</uploadfolder>
                        <show_thumbs>1</show_thumbs>
                        <size>1</size>
                        <maxitems>1</maxitems>
                        <minitems>0</minitems>
                    </config>
                </TCEforms>
                <type>no_map</type>
            </field_file>
        </el>
    </ROOT>
</T3DataStructure>

 

 Alert

You have to change one line in extension templavoila, to avoid the error.
Go go extension templavoila->pi->class.tx_templavoila_pi1.php
change the line
$cObj->start($dataRecord, '_NO_TABLE');
to
$cObj->start($dataRecord);