Skip to content

Instantly share code, notes, and snippets.

@gharlan
Last active August 1, 2016 19:42
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save gharlan/8df73c3059fc12af8fbbf8f2117292bf to your computer and use it in GitHub Desktop.
Save gharlan/8df73c3059fc12af8fbbf8f2117292bf to your computer and use it in GitHub Desktop.
Module mit Wrapper
<?php
if (rex::isBackend()) {
// Ausgabe im Backend ohne Wrapper
echo 'item';
return;
}
// Aktueller Slice
$slice = '<li>item</li>';
// Wrapper-Präfix und -Suffix
$prefix = '<ol>';
$suffix = '</ol>';
// Ab hier nichts verändern
if (!function_exists('rex_module_content_REX_MODULE_ID')) {
ob_start();
function rex_module_content_REX_MODULE_ID($prefix, $suffix, $slice)
{
static $content = '';
static $last = '';
$out = ob_get_clean();
if ($last != $out) {
echo $out;
$content = '';
}
ob_start();
$content .= $slice;
$last = $prefix.$content.$suffix;
echo $last;
}
}
rex_module_content_REX_MODULE_ID($prefix, $suffix, $slice);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment