Skip to content

Commit

Permalink
Allow using jdoc:include inside component
Browse files Browse the repository at this point in the history
  • Loading branch information
joomlart committed Dec 3, 2015
1 parent 48ab1de commit 77f3609
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions source/plg_system_t3/t3.php
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,33 @@ function onBeforeRender()
if (class_exists('T3Ajax')) {
T3Ajax::render();
}

// allow load module/modules in component using jdoc:include
$doc = JFactory::getDocument();
$main_content = $doc->getBuffer('component');
if ($main_content) {
// parse jdoc
if (preg_match_all('#<jdoc:include\ type="([^"]+)"(.*)\/>#iU', $main_content, $matches))
{
$replace = array();
$with = array();

// Step through the jdocs in reverse order.
for ($i = 0; $i < count($matches[0]); $i++)
{
$type = $matches[1][$i];
$attribs = empty($matches[2][$i]) ? array() : JUtility::parseAttributes($matches[2][$i]);
$name = isset($attribs['name']) ? $attribs['name'] : null;
$replace[] = $matches[0][$i];
$with[] = $doc->getBuffer($type, $name, $attribs);
}

$main_content = str_replace($replace, $with, $main_content);

// update buffer
$doc->setBuffer($main_content, 'component');
}
}
}
}
}
Expand Down

0 comments on commit 77f3609

Please sign in to comment.