Skip to content

Commit

Permalink
Fix template preview
Browse files Browse the repository at this point in the history
  • Loading branch information
Fedik committed Dec 9, 2021
1 parent ed1a749 commit 2ef95e4
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 20 deletions.
21 changes: 1 addition & 20 deletions libraries/src/Document/Renderer/Html/ModulesRenderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@

\defined('JPATH_PLATFORM') or die;

use Joomla\CMS\Component\ComponentHelper;
use Joomla\CMS\Document\DocumentRenderer;
use Joomla\CMS\Factory;
use Joomla\CMS\Helper\ModuleHelper;
Expand Down Expand Up @@ -43,26 +42,8 @@ public function render($position, $params = array(), $content = null)
$user = Factory::getUser();
$frontediting = ($app->isClient('site') && $app->get('frontediting', 1) && !$user->guest);
$menusEditing = ($app->get('frontediting', 1) == 2) && $user->authorise('core.edit', 'com_menus');
$modules = ModuleHelper::getModules($position);

// Prepend a dummy module for template preview
if ($app->input->getBool('tp') && ComponentHelper::getParams('com_templates')->get('template_positions_display'))
{
$dummy = (object) [
'id' => 0,
'module' => '',
'params' => '',
'showtitle' => 0,
'title' => $position,
'position' => $position,
'content' => $position,
'contentRendered' => true,
];

array_unshift($modules, $dummy);
}

foreach ($modules as $mod)
foreach (ModuleHelper::getModules($position) as $mod)
{
$moduleHtml = $renderer->render($mod, $params, $content);

Expand Down
13 changes: 13 additions & 0 deletions libraries/src/Helper/ModuleHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ public static function &getModules($position)
{
$position = strtolower($position);
$result = array();
$input = Factory::getApplication()->input;
$modules = &static::load();
$total = \count($modules);

Expand All @@ -96,6 +97,18 @@ public static function &getModules($position)
}
}

// Prepend a dummy module for template preview
if ($input->getBool('tp') && ComponentHelper::getParams('com_templates')->get('template_positions_display'))
{
$dummy = static::createDummyModule();
$dummy->title = $position;
$dummy->position = $position;
$dummy->content = $position;
$dummy->contentRendered = true;

array_unshift($result, $dummy);
}

return $result;
}

Expand Down

0 comments on commit 2ef95e4

Please sign in to comment.