[TYPO3-english] TS: is there a way to count() for elements GP-variable?
Bert Hiddink [BENDOO e-work solutions]
hiddink at bendoo.nl
Mon Dec 1 14:19:30 CET 2014
Hello Loek,
Thanks for your reply!
I tried the userfunc first, this works...
However, besides some constants, I need to pass the value of the current
uid to the userFunc (please see below) which is rendered from the 30.
object...
However, within the userFunc it passes the uid of the Page instead of
the uid of the current category...
Any idea how to resolve this?
Thanks again!
Regards,
Bert
#############
30 = CONTENT
30 {
table = sys_category
select {
pidInList = {$categoriesPid}
orderBy = sorting
where=deleted=0 AND hidden=0
andWhere.dataWrap = sys_language_uid={TSFE:sys_language_uid}
AND parent={field:uid}
}
renderObj = COA
renderObj {
39 = USER
39 {
userFunc = user_counter->getCounter
userFunc {
# whole string
selectedCategories=TEXT
selectedCategories.data =
GP:tx_news_pi1|overwriteDemand|categories
selectedPid={$categoriesPid}
currentUid=TEXT
currentUid.field=uid ###This passes the uid of the
current page instead of the current category
}
}
##############
<?php
class user_counter {
function getCounter($content = '', $conf = array()) {
// config
global $TSFE;
$local_cObj = $TSFE->cObj; // cObject
$conf = $conf['userFunc.']; // ts config
$selectedCategories=$local_cObj->cObjGetSingle($conf['selectedCategories'],
$conf['selectedCategories.']);
$currentUid=$local_cObj->cObjGetSingle($conf['currentUid'],
$conf['currentUid.']);
$countedCategories= count(explode(',', $selectedCategories));
$selectedPid=$conf['selectedPid'];
$currentLanguage=$GLOBALS['TSFE']->sys_language_uid;
$res = $GLOBALS['TYPO3_DB']->exec_SELECTquery(
'count(*) as counter',
...
);
while ($row = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) {
$counter = $row['counter'];
}
return $counter;
}
}
?>
More information about the TYPO3-english
mailing list