script

Thursday, February 21, 2013

loop in typo3 template

//in php code

$this->cObject = t3lib_div::makeInstance('tslib_cObj');
$templateFile = $this->conf['templateFile'] ? $this->conf['templateFile'] : 'EXT:abc/pi1/template/abc.html';
$this->template = $this->cObject->fileResource($templateFile);

// Extract the subparts from the template
$subparts['template'] = $this->cObj->getSubpart($this->template, '###MAIN_MARKER###');

$subparts['dropdown'] = $this->cObj->getSubpart($subparts['template'], '###DROPDOWN###');
$subparts['option'] = $this->cObj->getSubpart($subparts['dropdown'], '###OPTION###');


for($i=0;$i<10;$i++)
{
            // Fill marker array
            $loop['###LOOP_VAR###'] = $i;            
                                
            $contentItem .= $this->cObj->substituteMarkerArrayCached($subparts['option'], $loop);
 }
$subpartArray['###DROPDOWN###'] = $contentItem;
return $content = $this->cObj->substituteMarkerArrayCached($subparts['template'],null, $subpartArray,$markerArray);


//in html code
<select>
 <!-- ###DROPDOWN### begin -->
         <!-- ###OPTION### -->
                  <option value="###I###">###I###</option>
         <!-- ###OPTION### -->
<!-- ###DROPDOWN### end -->

</select>

Monday, February 18, 2013

Count based on condition in mysql

SELECT COUNT(IF(column=3,1,NULL)) AS Count
FROM table GROUP BY othercolumn