user2507818
user2507818

Reputation: 3047

Issue with TYPO3 extension and template

I am reading a TYPO3 extension.
This is the template file:

<!-- ###LIST_LATEST### begin -->
<div class="latest-wrapper">
    <ul class="listing latest">
        <li><h1>###LIST_HEADER###</h1></li>
        <!-- ###LOOP### --><!-- ###ITEM### --><li>
            <span class="category">###CATEGORY###</span><span class="company">###COMPANY_NAME###</span><span class="location">###LOCATION###, ###STATE### ###ZIP###</span>
        </li><!-- ###ITEM### --><!-- ###LOOP### -->
        <li class="more">###MORE###</li>
    </ul>
</div>
<!-- ###LIST_LATEST### end -->

In class.tx_jcjob_pi1.php, when put the contents into the template file, seems there are two ways:

a. for ###MORE###, use this method:

$markerArray['###MORE###'] = $this->cObj->getTypoLink($this->pi_getLL('text_link_more'), $this->conf['searchID'], array('tx_ajaxsearch_pi1[keyword]' => ''));
$content = $this->cObj->substituteMarkerArray($template, $markerArray);

b. for <!-- ###LOOP### -->, use this method:

$template = $this->cObj->substituteSubpart($template, '###LOOP###', $loopContent);  var_dump($template);

So my question is:

  1. What is the difference between ###MORE### and <!-- ###LOOP### -->?

  2. What is the difference between substituteMarkerArray and substituteSubpart?

Upvotes: 0

Views: 249

Answers (1)

Mateng
Mateng

Reputation: 3734

You are asking for the difference between two basic templating tools in TYPO3:

  1. Markers (###MORE###) and
  2. Subparts (<!-- ###LOOP### -->)

Both are placeholders to be replaced with dynamic content.

A marker represents a singular occurance. The string ###MORE### will be replaced by the function substituteMarker() or substituteMarkerArray() with whatever value you define in your php code.

A subpart always occurs in pairs; it has a beginning and an end marker. They enclose a range of code within which more values can be replaced. In your case, everything between the two <!-- ###LOOP### --> strings you find in your template can be processed by the function substituteSubpart(). Usually, this is used for list views when you loop over multiple results from your query. Within each subpart element you can replace markers or subparts recursively in your php code.

This blog post might give you some more insight into the principles.

Upvotes: 3

Related Questions