J3 Issue ?
avatar BrainforgeUK
BrainforgeUK
7 Aug 2020

Steps to reproduce the issue

$template1 = getMyTemplateStyleWithParameters();
JFactory::getApplication()->setTemplate($template1);
$template2 = JFactory::getApplication()->getTemplate(true);

Expected result

Expect getTemplate() to return what I passed into setTemplate().

Actual result

setTemplate() raises PHP error - needs to be passed a string not an object.
getTemplate() returns the default template for the current page.

System information (as much as possible)

Joomla 3.9.19

Additional comments

I expect setTemplate() to behave something like this ...

public function setTemplate($template, $styleParams = null)
{
	if (is_object($template))
	{
		$this->template->template = $template;
	}
	else if (is_dir(JPATH_THEMES . '/' . $template))
	{
		$this->template = new \stdClass;
		$this->template->template = $template;

		if ($styleParams instanceof Registry)
		{
			$this->template->params = $styleParams;
		}
		else
		{
			$this->template->params = new Registry($styleParams);
		}
	}
	// Store the template and its params to the config
	$this->set('theme', $this->template->template);
	$this->set('themeParams', $this->template->params);
}
avatar BrainforgeUK BrainforgeUK - open - 7 Aug 2020
avatar joomla-cms-bot joomla-cms-bot - labeled - 7 Aug 2020
avatar alikon alikon - change - 7 Aug 2020
Labels Added: J3 Issue
avatar alikon alikon - labeled - 7 Aug 2020
avatar BrainforgeUK BrainforgeUK - change - 28 Jul 2021
Status New Closed
Closed_Date 0000-00-00 00:00:00 2021-07-28 11:22:51
Closed_By BrainforgeUK
avatar BrainforgeUK BrainforgeUK - close - 28 Jul 2021

Add a Comment

Login with GitHub to post a comment