Author Topic: Bug causes template load to fail  (Read 1594 times)

anthrobote

  • Beginner
  • *
  • Posts: 8
Bug causes template load to fail
« on: December 13, 2011, 13:25:19 pm »
Description:
If the extension name of a template (inside the <name> element in templateDetails.xml) differs from the directory name in which the template is stored (e.g. /templates/template-directory-name/), the template load process will fail due to the bug in .../helpers/shopfunctions.php (currently at line 516).  In the current state, $template->value variable (which is later accessed in the view) equals $template->name which contains the extension name, not the directory name. Afterwards, $template->value is used in a select box in .../config/tmpl/default_templates.php (currently at line 38) as the value attribute of <option> elements (the 5th parameter of JHTML::_(..)) and later stored in the database when selected and confirmed in VMM administration by user . The stored value is fetched during the template load process and used to construct the template path in .../helpers/shopfunctionsf.php (currently at line 451) inside the is_dir() check for template existence – failing to succeed and raising the warning "The choosen template couldnt found on the filesystem".

VirtueMart Version:
1.9.8M

Joomla/Mambo Version:
1.7.3

Proposed fix(es):
Replace:

Code: [Select]
$template->value = $template->name;
in .../helpers/shopfunctions.php (currently at line 516) with:

Code: [Select]
$template->value = $template->directory;
so it can be used correctly in .../config/tmpl/default_templates.php (currently at line 38), or change the JHTML::_('Select.genericlist',..) call so it uses 'directory' member variable as the 'value' attribute for the generated <option> elements like this:
 
Code: [Select]
echo JHTML::_('Select.genericlist', $this->jTemplateList, 'vmtemplate', 'size=1 width=200', 'directory', 'name', $this->config->get('vmtemplate'));
Then the templates successfully load irrespective of their "extension" name specified in templateDetails.xml.

Bugtracker task #:
Not submitted yet.

Milbo

  • Virtuemart Projectleader
  • Administrator
  • Super Hero
  • *
  • Posts: 9843
  • VM3.2 Cached and Optimized
    • VM3 Extensions
  • VirtueMart Version: VirtueMart 3 on joomla 3
Re: Bug causes template load to fail
« Reply #1 on: December 13, 2011, 14:45:47 pm »
Hmm we have this in line 518:
Code: [Select]
foreach ($jtemplates as $key => $template) {
$template->value = $template->name;
if (!$isJ15) {
if ($template->client_id == '0') {
$template->directory = $template->element;
} else {
unset($jtemplates[$key]);
}
}
}
So it is related to j1.5 and j1.7 differences. Did you test the K version? and how is this handled in j1.5? Is it actually valid to have a different path than element name?
I should fix your bug, please support the VirtueMart project and become a member
______________________________________
Extensions approved by the core team: http://extensions.virtuemart.net/

anthrobote

  • Beginner
  • *
  • Posts: 8
Re: Bug causes template load to fail
« Reply #2 on: December 13, 2011, 23:51:10 pm »
I didn't get so far, I have installed and tested just 1.7.3, can somebody do the tests?

It seems it's partly valid - Joomla recognizes the template only if the names matches except the case of the letters. For example Artisteer editor generates templates with names being the same except the case, but it still may cause a problem on a case-sensitive filesystem. So I think the path would be safer here. I have not found any documentation on this.