Skip to content

Commit

Permalink
🐛 fix the menu assigned template design not working issue
Browse files Browse the repository at this point in the history
  • Loading branch information
ahamed committed Jul 16, 2021
1 parent d748d69 commit 63b6463
Show file tree
Hide file tree
Showing 2 changed files with 69 additions and 38 deletions.
18 changes: 11 additions & 7 deletions plugins/system/helixultimate/helixultimate.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,17 +70,21 @@ class PlgSystemHelixultimate extends JPlugin
public function onAfterInitialise()
{
$template = Helper::loadTemplateData();
$bootstrapPath = JPATH_ROOT . '/templates/' . $template->template . '/html/layouts/libraries/cms/html/bootstrap.php';

if ($this->app->isClient('site') && \file_exists($bootstrapPath))
if (isset($template->template) && !empty($template->template))
{
if (!class_exists('HelixBootstrap'))
$bootstrapPath = JPATH_ROOT . '/templates/' . $template->template . '/html/layouts/libraries/cms/html/bootstrap.php';

if ($this->app->isClient('site') && \file_exists($bootstrapPath))
{
require_once $bootstrapPath;
}
if (!class_exists('HelixBootstrap'))
{
require_once $bootstrapPath;
}

HTMLHelper::register('bootstrap.tooltip', ['HelixBootstrap', 'tooltip']);
HTMLHelper::register('bootstrap.popover', ['HelixBootstrap', 'popover']);
HTMLHelper::register('bootstrap.tooltip', ['HelixBootstrap', 'tooltip']);
HTMLHelper::register('bootstrap.popover', ['HelixBootstrap', 'popover']);
}
}
}

Expand Down
89 changes: 58 additions & 31 deletions plugins/system/helixultimate/src/Platform/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -248,10 +248,22 @@ public static function loadTemplateData()
{
$templateId = 0;
$app = Factory::getApplication();

if ($app->isClient('site'))
{
$currentTemplate = $app->getTemplate(true);
$templateId = $currentTemplate->id ?? 0;

/**
* If a page/menu is assigned to a specific template
* then get the template ID.
*/
$activeMenu = $app->getMenu()->getActive();

if (!empty($activeMenu))
{
$templateId = $activeMenu->template_style_id;
}
}
else
{
Expand All @@ -260,20 +272,26 @@ public static function loadTemplateData()
$templateId = $app->input->get('id', 0, 'INT');
}
}

if (empty($templateId))
{
$templateId = $app->input->get('helix_id', 0, 'INT');
}

if($templateId)
{
$template = [];

$draftKeyOptions = [
'option' => 'com_ajax',
'helix' => 'ultimate',
'status' => 'draft',
'id' => $templateId
];

$draftKey = self::generateKey($draftKeyOptions);
$cache = new HelixCache($draftKey);

/**
* Check the fetch destination. If it is iframe then load the settings
* from draft, otherwise if it is document that means this request
Expand Down Expand Up @@ -306,36 +324,45 @@ public static function loadTemplateData()
$template = self::getTemplateStyle($templateId);
}
}

if (!empty($template->params) && \is_string($template->params))
{
$template->params = new Registry($template->params);
}
/**
* If params field is found empty in the database or cache then
* read the default options.json file from the template and assign
* the options as template params.
*/
elseif (empty($template->params))
{
$filePath = JPATH_ROOT . '/templates/' . $template->template . '/' . 'options.json';

if (\file_exists($filePath))
{
$defaultParams = \file_get_contents($filePath);
$template->params = new Registry($defaultParams);
}
else
{
$template->params = new Registry;
}
}

return $template;

// echo '<xmp>';
// print_r($template);
// echo '</xmp>';

if (isset($template->template) && !empty($template->template))
{
if (!empty($template->params) && \is_string($template->params))
{
$template->params = new Registry($template->params);
}
/**
* If params field is found empty in the database or cache then
* read the default options.json file from the template and assign
* the options as template params.
*/
elseif (empty($template->params))
{
$filePath = JPATH_ROOT . '/templates/' . $template->template . '/' . 'options.json';

if (\file_exists($filePath))
{
$defaultParams = \file_get_contents($filePath);
$template->params = new Registry($defaultParams);
}
else
{
$template->params = new Registry;
}
}

return $template;
}
}
$template = new \stdClass();
$template->template = '';

$template = new \stdClass;
$template->template = 'system';
$template->params = new Registry;

return $template;
}

Expand Down

0 comments on commit 63b6463

Please sign in to comment.