Question

I'm using old fashion way (kickstarter) to build extension in TYPO3. I would like to ad some PHP code after third element of list, but I really don't know how to do this.

My code looks like that:

protected function makeList($res) {
    $items = array();
        // Make list table rows
    while (($this->internal['currentRow'] = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) !== FALSE) {
        $items[] = $this->makeListItem();
    }

    $out = '<div' . $this->pi_classParam('listrow') . '>list items</div>';
    return $out;
}

And:

protected function makeListItem() {
    $out = 'list item details';
    return $out;
}
Was it helpful?

Solution

If I understood correctly, you would need something like this:

protected function makeList($res) {
    $items = array();
    // Make list table rows
    $i = 0;
    $out = '<div' . $this->pi_classParam('listrow') . '>';
    while (($this->internal['currentRow'] = $GLOBALS['TYPO3_DB']->sql_fetch_assoc($res)) !== FALSE) {

        $out .= $this->makeListItem();
        $i++;
        if ($i == 3) {
             $out .= '<img src="whateverjpg">';
             $i = 0; // if you want to do it every 3 images
        }            
    }


    $out .= '</div>';
    return $out;
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top