[TYPO3-commerce] Download of PDF in singleview (solved)

rainer schleevoigt rainer at webmasterei-hamburg.de
Wed Sep 30 13:52:20 CEST 2009


rainer schleevoigt schrieb:
> Hi,
> 
> now I found:

In 
http://typo3.org/fileadmin/typo3api-4.0.0/d3/d3d/classt3lib__div.html#e93bfe1156fa2d796aa928a7d81afb90

I found 'Required prefix of class name. By default "tx_" is allowed.'
I changed the name of my class and it works fine.

Rainer

> 
> the right name ist ext_localconf.php (and not localconf.php)
> 
> My hookclass is embedding, because outside the class an 
> error_log('TEST') works fine.
> 
> But the methodes in the class are not calling. I think the problem is 
> the syntax of hookname.
> 
> 
> 
> $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/lib/class.tx_commerce_pibase.php']['singleview'][] 
> = $hookname;
> $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/lib/class.tx_commerce_product.php']['postinit'][] 
>  = $hookname;
> 
> 
> The name of my extension is 'ras_lupobello'.
> The filename of class is 'hookclass.php' and the classname is 
> 'ext_lupohook'.
> 
> So I think
> '$hookname='EXT:ras_lupobello/hookclass.php:ext_lupohook';' is the right 
> hookname, but the methods are not calling.
> 
> Here is the full code of hookclass.php:
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> <?php
> error_log('HOOKCALLING');
> class ext_lupohook {
>     public function postInit(&$model) {
>     error_log('INIT');
>            $model->add_fields_to_fieldlist(array('tx_raslupobello_pdf'));
>     }   
>     
>     public function additionalMarker($markerArray,$singleViewPlugin) {
>     error_log('MARKER');
>     $markerArray['###PDF###'] = 
> $singleViewPlugin->product->getField('tx_raslupobello_pdf');
>     return $markerArray;
>     }
> }
> ?>
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> 
> 
> 
>> Hi Morten,
>>
>> I have changed my localconf.php and I see that this file is not 
>> called, because this snippet is in it:
>> ~~~~~~~~~~~~~~~~~~
>> error_log('LOCAL_TEST__CONF'); // this string doesnt appear in error-log
>>
>> $lupohook='EXT:ras_lupobello/hookclass.php:ext_lupohook';
>> $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/lib/class.tx_commerce_pibase.php']['singleview'][] 
>> = $lupohook;
>> $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/lib/class.tx_commerce_product.php']['postinit'][] 
>> = $lupohook;
>> ~~~~~~~~~~~~~~~~~~
>>
>> Here is the content of hookclass.php:
>> ~~~~~~~~~~~~~~~~~~
>> class ext_lupohook {
>>     function postInit(&$model) {
>>             error_log('INIT');
>>            $model->add_fields_to_fieldlist(array('tx_raslupobello_pdf'));
>>     }           function 
>> additionalMarker($markerArray,$singleViewPlugin) {
>>         error_log('MARKER');
>>         $markerArray['###PDF###'] = 
>> $singleViewPlugin->product->getField('tx_raslupobello_pdf');
>>         return $markerArray;
>>     }
>> }
>> ~~~~~~~~~~~~~~~~~~
>>
>> Di you have an idea why the localconf.php ist not calling?
>>
>>
>> Rainer
>>
>>
>>
>>
>>
>>
>>  Olesen schrieb:
>>> Hi Rainer,
>>>
>>>
>>> You are on the right track - the hooks should be initialized in 
>>> localconf.php of your extension - rather than include it your self 
>>> you can left commerce do it. This way the class will only be loaded 
>>> when it's needed
>>>
>>>
>>> example localconf.php - assuming your extension dir is named 
>>> raslupobello :
>>>
>>> <?php
>>> if (!defined ('TYPO3_MODE'))     die ('Access denied.');
>>> $lupohook='EXT:raslupobello/hookclass.php:user_lupohook';
>>> $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/lib/class.tx_commerce_pibase.php']['singleview'][]=$lupohook; 
>>>
>>> $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/lib/class.tx_commerce_product.php']['postinit'][]=$lupohook; 
>>>
>>>
>>> ?>
>>>
>>> After this change ( and indeed any change to localconf.php ) you will 
>>> need to clear the cache to allow typo3 to rebuild it's combined 
>>> config file.
>>>
>>>
>>> if this still doesn't work for you then the problem lies else where.
>>>
>>> /Morten
>>>
>>> rainer schleevoigt wrote:
>>>> Hi,
>>>>
>>>> in my template file I have inserted ###PDF###.
>>>>
>>>> I created a extension width the new field 'tx_raslupobello_pdf' in 
>>>> tx_commerce_products. The client can upload pdf.
>>>>
>>>> Now comes my problem in FE:
>>>>
>>>> In this extension I created a file with the content:
>>>>
>>>> =================
>>>> class user_lupohook {
>>>>   function postInit(&$model) {
>>>>                    
>>>> $model->add_fields_to_fieldlist(array('tx_raslupobello_pdf'));
>>>>     }
>>>>       function additionalMarker($markerArray,$singleViewPlugin) {
>>>>         $markerArray['###PDF###'] = 
>>>> $singleViewPlugin->product->getField('tx_raslupobello_pdf');
>>>>         return $markerArray;
>>>>     }
>>>> }
>>>> =================
>>>>
>>>> Inserting of
>>>>
>>>> require_once(t3lib_extMgm::extPath($_EXTKEY).'hookclass.php');
>>>> $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/lib/class.tx_commerce_pibase.php']['singleview'][] 
>>>> = 'user_lupohook';
>>>> $GLOBALS['TYPO3_CONF_VARS']['EXTCONF']['commerce/lib/class.tx_commerce_product.php']['postinit'][] 
>>>>  = 'user_lupohook';
>>>>
>>>> in localconf.php doesnt work.
>>>>
>>>> It works after clearing of cache one time, if I place the code in 
>>>> ext_tables.php. After reloading of FE-page the marker doesnt replace.
>>>>
>>>> Any ideas?
>>>>
>>>>
>>>> Rainer


More information about the TYPO3-project-commerce mailing list