[TYPO3-commerce] 'hardcoded' rendering of TS driven objects should be changed!
Franz Koch
typo.removeformessage at fx-graefix.de
Wed Aug 29 18:29:13 CEST 2007
Hi (me again ;-) ),
I was just wondering why the images didn't show up and digged the source
a bit and found some stuff that could be improved. Especially the method
'renderValue' of class.tx_commerce_pibase.php.
Currently the 'design' of the TS-objects must be in a strict way,
because some parts of the TS-code get overwritten with hardcoded php.
This is not the best way - in fact it's ugly and not very flexible. So I
suggest the following:
1. provide a local_cObject
---------------------------
function init($conf) {
#...
$this->local_cObject = t3lib_div::makeInstance('tslib_cObj');
#...
}
---------------------------
2. call cObjGetSingle instead of the objects directly
Therefore the calls to the method renderValue have to be
changed slightly to also provide the data of the current record
(article, category, product)
---------------------------
function renderValue(&$value,&$data,&$TSfield,&$TSconf) {
$this->local_cObject->data = $data;
$this->local_cObject->setCurrentVal($value);
return
$this->local_cObj->cObjGetSingle($TSconf[$TSfield],$TSconf[$TSfield.'.']);
}
---------------------------
3. change the TS for the rendering
---------------------------
lib.tx_commerce {
products.fields.images = IMAGE
products.fields.images {
// a constant could also be used for the uploadFolder
// as it is also defined/used somewhere else in TS
file.import = uploads/tx_commerce/
file.import.current = 1
altText.field = title
}
}
---------------------------
That way you open up commerce the full power and flexibility of TS and
would allow for GIFBUILDER, combining extensions (like connecting some
commenting-extension or whatever directly with TS) and much more.
Changing this method is also no big deal, because it is only called on
one place in the whole code of commerce, named 'generateMarkerArray'.
If your're interested I could try to create a diff for all what is
needed to be changed (TS and php-class).
--
Kind regards,
Franz Koch
More information about the TYPO3-project-commerce
mailing list