Skip to content

Commit

Permalink
Improved template fallback handling
Browse files Browse the repository at this point in the history
  • Loading branch information
mollierobbert committed Dec 10, 2014
1 parent a49f79b commit 6dd111a
Showing 1 changed file with 14 additions and 16 deletions.
30 changes: 14 additions & 16 deletions catalog/controller/payment/mollie_ideal.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,18 +118,8 @@ public function index ()
$data['mollie_method'] = $this->session->data['mollie_method'];
}

// Check if view is at default template else use modified template path
if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/payment/mollie_checkout_form.tpl'))
{
$template = $this->config->get('config_template') . '/template/payment/mollie_checkout_form.tpl';
}
else
{
$template = 'default/template/payment/mollie_checkout_form.tpl';
}

// Return HTML output - it will get appended to confirm.tpl.
return $this->renderTemplate($template, $data, array(), FALSE);
return $this->renderTemplate("mollie_checkout_form", $data, array(), FALSE);
}

/**
Expand Down Expand Up @@ -523,23 +513,31 @@ protected function renderTemplate ($template, $data, $common_children = array(),
}

/**
* Fetch path to a template file. Allows themes to overwrite the template. Prefers *_2.tpl for Opencart 2 specific layouts.
*
* @param string $template
*
* @return string
*/
protected function getTemplatePath ($template)
{
$template = "template/payment/" . $template;
$config_template = $this->config->get("config_template");
$possible_paths = [];

if ($this->isOpencart2())
{
$template .= "_2";
$possible_paths[] = $config_template . "/" . $template . "_2.tpl";
$possible_paths[] = "default/" . $template . "_2.tpl";
}

// Check if template exists
if (file_exists(DIR_TEMPLATE . $this->config->get("config_template") . "/" . $template . ".tpl"))
$possible_paths[] = $config_template . "/" . $template . ".tpl";

foreach ($possible_paths as $path)
{
return $this->config->get("config_template") . "/" . $template . ".tpl";
if (file_exists(DIR_TEMPLATE . $path))
{
return $path;
}
}

return "default/" . $template . ".tpl";
Expand Down

0 comments on commit 6dd111a

Please sign in to comment.