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>

1 comment:

  1. I really appreciate information shared above. It’s of great help. If someone want to learn Online (Virtual) instructor lead live training in Typo3, kindly contact us http://www.maxmunus.com/contact
    MaxMunus Offer World Class Virtual Instructor led training on Typo3. We have industry expert trainer. We provide Training Material and Software Support. MaxMunus has successfully conducted 100000+ trainings in India, USA, UK, Australlia, Switzerland, Qatar, Saudi Arabia, Bangladesh, Bahrain and UAE etc.
    For Demo Contact us:
    Name : Arunkumar U
    Email : arun@maxmunus.com
    Skype id: training_maxmunus
    Contact No.-+91-9738507310
    Company Website –http://www.maxmunus.com


    ReplyDelete