.. ================================================== .. FOR YOUR INFORMATION .. -------------------------------------------------- .. -*- coding: utf-8 -*- with BOM. .. include:: ../../../../Includes.txt .. _developers_methods_core_service: Service ======= .. _methods_core_service_markerbasedtemplateservice_getSubpart: getSubpart() ------------ What does it do? ^^^^^^^^^^^^^^^^ Substitutes a marker string in the input content. Header ^^^^^^ .. code:: php /** * Substitutes a marker string in the input content * (by a simple str_replace()) * * @param string $content The content stream, typically HTML template content. * @param string $marker The marker string, typically on the form "###[the marker string]### * @param mixed $markContent The content to insert instead of the marker string found. * * @return string The processed HTML content string. * @see substituteSubpart() */ public function getSubpart( $content, $marker ) Sample ^^^^^^ .. code:: php $MarkerBasedTemplateService = GeneralUtility::makeInstance( \Netzmacher\Refresh\Compatibility\Core\Service\MarkerBasedTemplateService::class ); $ajaxSubpartOfTheTemplate = $MarkerBasedTemplateService->getSubpart( $template, '###AJAX###' ); Refresh ^^^^^^^ You can refresh your extension by find and replace. .. code:: php // Code from TYPO3 6.2 to 7.6 $ajaxSubpartOfTheTemplate = $this->cObj->etSubpart( $template, '###AJAX###' ); // Code from TYPO3 6.2 to 9.x $ajaxSubpartOfTheTemplate = $MarkerBasedTemplateService->getSubpart( $template, '###AJAX###' ); Move "$this->cObj->getSubpart" to "$MarkerBasedTemplateService->getSubpart" .. _methods_core_service_markerbasedtemplateservice_substituteMarker: substituteMarker() ------------------ What does it do? ^^^^^^^^^^^^^^^^ Substitutes a marker string in the input content. Header ^^^^^^ .. code:: php /** * Substitutes a marker string in the input content * (by a simple str_replace()) * * @param string $content The content stream, typically HTML template content. * @param string $marker The marker string, typically on the form "###[the marker string]### * @param mixed $markContent The content to insert instead of the marker string found. * * @return string The processed HTML content string. * @see substituteSubpart() * @access public * @internal #t1655 * @version 1.0.0 * @since 1.0.0 */ public function substituteMarker( $content, $marker, $markContent ) Sample ^^^^^^ See :ref:`getSubpart() ` above. Refresh ^^^^^^^ See :ref:`getSubpart() ` above. .. _methods_core_service_markerbasedtemplateservice_substituteMarkerArray: substituteMarkerArray() ----------------------- What does it do? ^^^^^^^^^^^^^^^^ Substitutes a marker array in the input content. Header ^^^^^^ .. code:: php /** * Traverses the input $markContentArray array and for each key the marker * by the same name (possibly wrapped and in upper case) will be * substituted with the keys value in the array. This is very useful if you * have a data-record to substitute in some content. In particular when you * use the $wrap and $uppercase values to pre-process the markers. Eg. a * key name like "myfield" could effectively be represented by the marker * "###MYFIELD###" if the wrap value was "###|###" and the $uppercase * boolean TRUE. * * @param string $content The content stream, typically HTML template content. * @param array $markContentArray The array of key/value pairs being marker/content values used in the substitution. For each element in this array the function will substitute a marker in the content stream with the content. * @param string $wrap A wrap value - [part 1] | [part 2] - for the markers before substitution * @param bool $uppercase If set, all marker string substitution is done with upper-case markers. * @param bool $deleteUnused If set, all unused marker are deleted. * * @return string The processed output stream * @see substituteMarker(), substituteMarkerInObject(), TEMPLATE() * @access public */ public function substituteMarkerArray( $content, array $markContentArray, $wrap = '', $uppercase = FALSE, $deleteUnused = FALSE ) Sample ^^^^^^ See :ref:`getSubpart() ` above. Refresh ^^^^^^^ See :ref:`getSubpart() ` above. .. _methods_core_service_markerbasedtemplateservice_substituteMarkerArrayCached: substituteMarkerArrayCached() ----------------------------- What does it do? ^^^^^^^^^^^^^^^^ Multi substitution function with caching. Header ^^^^^^ .. code:: php /** * Multi substitution function with caching. * * This function should be a one-stop substitution function for working * with HTML-template. It does not substitute by str_replace but by * splitting. This secures that the value inserted does not themselves * contain markers or subparts. * * Note that the "caching" won't cache the content of the substition, * but only the splitting of the template in various parts. So if you * want only one cache-entry per template, make sure you always pass the * exact same set of marker/subpart keys. Else you will be flooding the * user's cache table. * * This function takes three kinds of substitutions in one: * $markContentArray is a regular marker-array where the 'keys' are * substituted in $content with their values * * $subpartContentArray works exactly like markContentArray only is whole * subparts substituted and not only a single marker. * * $wrappedSubpartContentArray is an array of arrays with 0/1 keys where * the subparts pointed to by the main key is wrapped with the 0/1 value * alternating. * * @param string $content The content stream, typically HTML template content. * @param array $markContentArray Regular marker-array where the 'keys' are substituted in $content with their values * @param array $subpartContentArray Exactly like markContentArray only is whole subparts substituted and not only a single marker. * @param array $wrappedSubpartContentArray An array of arrays with 0/1 keys where the subparts pointed to by the main key is wrapped with the 0/1 value alternating. * @return string The output content stream * @see substituteSubpart(), substituteMarker(), substituteMarkerInObject(), TEMPLATE() * @access public * @internal #t1818 * @version 1.0.2 * @since 1.0.2 */ public function substituteMarkerArrayCached( $content, array $markContentArray = null, array $subpartContentArray = null, array $wrappedSubpartContentArray = null ) Sample ^^^^^^ See :ref:`getSubpart() ` above. Refresh ^^^^^^^ See :ref:`getSubpart() ` above. .. _methods_core_service_markerbasedtemplateservice_substituteSubpart: substituteSubpart() ------------------- What does it do? ^^^^^^^^^^^^^^^^ Substitute subpart in input template stream. Header ^^^^^^ .. code:: php /** * Substitute subpart in input template stream. * This function substitutes a subpart in $content with the content of * $subpartContent. * Wrapper for \TYPO3\CMS\Core\Html\HtmlParser::substituteSubpart which behaves identical * * @param string $content The content stream, typically HTML template content. * @param string $marker The marker string, typically on the form "###[the marker string]### * @param mixed $subpartContent The content to insert instead of the subpart found. If a string, then just plain substitution happens (includes removing the HTML comments of the subpart if found). If $subpartContent happens to be an array, it's [0] and [1] elements are wrapped around the EXISTING content of the subpart (fetched by getSubpart()) thereby not removing the original content. * @param boolean $recursive If $recursive is set, the function calls itself with the content set to the remaining part of the content after the second marker. This means that proceding subparts are ALSO substituted! * @return string The processed HTML content string. * @access public */ public function substituteSubpart( $content, $marker, $subpartContent, $recursive = 1 ) Sample ^^^^^^ See :ref:`getSubpart() ` above. Refresh ^^^^^^^ See :ref:`getSubpart() ` above.